Syntax for referencing a subform

dc.gypsy

New member
Local time
Today, 04:08
Joined
Sep 20, 2004
Messages
7
Newbie question: I have a datasheet view subform (called "UpdateProjectsSubform") in an "empty" form. I set it up this way because I was unable to get the Switchboard to open the subform in datasheet view.

I would like to have a command button to set filters in the subform. As I cannot have a button in datasheet view, I think my best option is to place a button on the master form that performs the command on the subform. I have tried every which way, but can't seem to get the correct syntax to reference the subform. I have searched this forum as well as other references with no success. Any ideas?

Thanks!
Nancy
 
Weird behavior but you still can do what you want.

Place a button on the main form
Select a "Form operation" for a type of command
Select an "Edit form filter"
Click "Finish"
NOW in the properties of the button modify "on click" event to

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 0, 0, acMenuVer70
 
Thanks, Alexei. That got me part-way there. The form opened and allowed me to select my filters, but when I selected the "Apply Filter" button nothing happened, and the "Remove Filter" button was grayed out.

How do I take this the next step, then, to get the user from selecting criteria to applying as well as removing the criteria?

Also, in your command, could you please explain what "0,0" refers to?

Thanks much,
Nancy
 
I am sorry
Unfortunately you would have to drop the idea of having the main form and the subform. Because the filter is applied only on the main form. May be it would be easier to mimic the datasheet view. Because by placing the buttons on the continuous form everything is working and everything is fine :)

acRecordsMenu, 0, 0 means
on the menu bar select "Records",
select first menu under the "records",
select the first submenu under the first menu.
 
Hmmm...I got the idea to place the datasheet view in a subform from this list, as the switchboard won't open a main form in that view. Thanks anyway for your help in answering my question. Perhaps someone will have an alternative suggestion.

Cheers,
Nancy
 
Go to the Modules tab
Open a module and paste the following:

Function OpenDSView()
On Error GoTo OpenDSView_Err

DoCmd.OpenForm "Your form name", acFormDS, "", "", , acNormal


OpenDSView_Exit:
Exit Function

OpenDSView_Err:
MsgBox Error$
Resume OpenDSView_Exit

End Function

Ofcourse do not forget to put instead of "your form name" the name of the form you are trying to open in datasheet view.
Then go to the switchboard manager and modify the the item which is supposed to open your form to :
Command: Run code
Function name: OpenDSView

Voila.
 
Alexei,

I followed your instructions, but got an error message after pressing the selection on the switchboard. Unfortunately, the message simply said "There was an error executing the command": not much help. Here's the module I created (named OpenDSView):
-----------------------
Function OpenDSView()
On Error GoTo OpenDSView_Err

DoCmd.OpenForm "Datasheet", acFormDS, "", "", , acNormal

OpenDSView_Exit:
Exit Function

OpenDSView_Err:
MsgBox Error$
Resume OpenDSView_Exit

End Function
------------------------
Thanking you in advance for your patience,
Nancy
 

Users who are viewing this thread

Back
Top Bottom