# Access-Command button to open form in datasheet view



## Diane Herron (Dec 28, 2000)

I think I'm losing my mind. Have created a command button to open a form. The form I want to open is set to Datasheet view. Everytime I click the button, the form opens in Single Form view. I can also set it to Continuous Form view which will work. But, it doesn't matter if I set it to Datasheet or Single, it will only open in Single view when I click the button.

By the way, when I simply open the form (without clicking the button to open it), it works fine.

Thanks for any help!


----------



## downwitchyobadself (Oct 13, 2000)

Look at the code under [Event Procedure] on the command button in question, by clicking on the ... button to the right of the line in the control properties window. I'll bet it says something like this:

DoCmd.OpenForm "MyFormName", acNormal

Or nothing at all after "MyFormName", since acNormal is the default. Make it say

DoCmd.OpenForm "MyFormName", acFormDS

instead.

Hope that helps.


----------



## Diane Herron (Dec 28, 2000)

Thanks for the response. However, I am not familiar with Event Procedures (not a real experienced Access user). This command button was created with a macro where I simply selected the OpenForm action. The form I want to open is set to Datasheet for the Default View. It opens in Datasheet view when I just open it by itself (without using the button). 

Any other help you can offer?

Thanks!
Diane


----------



## Diane Herron (Dec 28, 2000)

Hey, I just copied your suggestion for the Event Procedure and it worked. However, one problem always seems to lead to another. The problem now is just weird. I will attempt to explain it.

When I click the button, the form opens in Datasheet view on top of the other form. I close the form that was opened by clicking the button and I just have solid gray appearing where the form was. The computer seems to be locked up and my only alternative is to close Access. I've opened Access and tried this several times and it happens every time.

Thanks,
Diane


----------



## downwitchyobadself (Oct 13, 2000)

I don't really understand either of your posts, I'm afraid. Could you post the macro procedure with arguments and the event procedure here?


----------



## Diane Herron (Dec 28, 2000)

You can disregard the first post. The second post that states "I copied the Event Procedure and it works", is the one I'm having trouble with. The procedure does work in that it opens the form in Datasheet view. However, I am then unable to do anything else other than close Access. I have attached a picture to illustrate what I'm talking about.

Thanks for all your help.


----------



## downwitchyobadself (Oct 13, 2000)

That's why I asked you to post the code; I understood what was happening, I just wanted to see the event procedure itself.

It's an improperly terminated echo statement. You are somewhere in your code saying "echo false" or "application.echo false", and at the end of your procedure you need an "echo true" statement to match it.

Echo turns on/off screen updating.


----------



## Diane Herron (Dec 28, 2000)

Thank you soooo much. I entered the "Echo true" and worked perfectly!


----------

