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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a recordsource and filter to a form

Status
Not open for further replies.

bopritchard

Programmer
Jan 27, 2003
199
US
i'm doing the following
DoCmd.OpenForm stDocName, acNormal, filterName, whereclause

where
stDocName is the name of the form
filterName is the name of a valid query
whereclause is my filter criteria

but on the formload of the form i'm opening the recordsouce and the filter are null and of course no data shows up in the form

what am i doing wrong
 
Look at the help file on DoCmd.OpenForm... I believe that your field names in the query must exactly match the field names that are a part of the form's recordsource already.

That means that your recordsource for the form must be set to something to begin with. Have you done that?
 
you can create your own OpenForm method with the relevant data criteria passed as parameters. An example would be:

code in the called form

Public Sub OpenForm(byval pSQL As String,byval pFilter As String)
Me.RecordSource = pSQL
Me.Filter = pFilter
Me.FilterOn = True
Me.Visible = True
End Sub

calling code
module level to stop it going out of scope!!!
Private frmX As Form_ ...... whatever your form

code from the relevant procedure
Set frmX = New Form_ ...... whatever your form
frmX.OpenForm(sql,filter)

hth
regards
steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top