Using Buttons to display datasheets

B

Bill

I setup a form that has a button on it that runs a form. How can I get that
button to run the form, but display the results as a datasheet? If I click
on the form directly, it shows the datasheet. Using a button on another form
does not.
 
F

fredg

I setup a form that has a button on it that runs a form. How can I get that
button to run the form, but display the results as a datasheet? If I click
on the form directly, it shows the datasheet. Using a button on another form
does not.

Regardless of a form's Default View setting, if you wish to open it i
in Datasheet View using code you MUST specify Datasheet View.

DoCmd.OpenForm "FormName", acFormDS
 
B

Bill

Fred, thank you for your quick response. Where do I put the code?
DoCmd.OpenForm "H - Point Leaders", acFormDS.
 
F

fredg

Fred, thank you for your quick response. Where do I put the code?
DoCmd.OpenForm "H - Point Leaders", acFormDS.

From your previous message ...
" setup a form that has a button on it that runs a form. "

This is an already existing button on the form?
Open your form in design view.
Select the Command button you are using to open the form.
Display the Button's Property sheet.
Select the Event tab.
On the On Click event line it should say [Event Procedure].
Click on that line.
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens it will have some existing code that opens
the other form.
It will read something like:
DoCmd.OpenForm "H - Point Leaders"

Change that line to
DoCmd.OpenForm "H - Point Leaders", acFormDS
Save the changes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top