Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a form recordset based on command button 1

Status
Not open for further replies.

Garyhou

Technical User
Sep 19, 2003
12
US
I would like to define the query to use when opening a form based on command buttons on the mainscreen form. I've tried using a public variable defined on the mainscreen form (under general declarations) which I set to the appropriate query name at the command button (which opens the form) but this does not come across to the form being opened.

example: mainform form

General declarations

public stqueryname as string



open form cmd button

stqueryname = "qrydwgreview"

docmd.openform -----


then on the form to be opened:

Private Sub Form_Open(Cancel As Integer)


Me.RecordSource = stqueryname

End Sub


This form does not recognize the stqueryname variable.

Any suggestions?

Thanks
 
Put the Public declaration of stqueryname in a standard code module (not a Form module).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Better search for "OpenArgs" in the help file. You have more control on form with it.

________________________________________________________________________
Zameer Abdulla
Visit Me
By the time a man realizes that may be his father was right,
he usually has a son who says,
"Father, you are wrong!".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top