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

openform with new recordsource

Status
Not open for further replies.

jerry23

Technical User
Jun 14, 2002
7
US
How can I open a form and assign it a new recordsource.
I have a form based on a query, but I also want to open it based on the same query but filtered.
docmd.openform ,me.recordsource = xxxx ??

any help greatly appreciated...
 
Are you looking to assign it a recordsource from another table(s) or a filtered version of the original query?

Rhonin
"Note: before seppuku, hire maid..."
 
Dim DocName As String, WhereClause As String
Dim QUOTE as String
QUOTE = $chr(34)

DocName = "TheFormToOpen"
WhereClause = " componentType = " & QUOTE & CBComponentType & QUOTE
'---- this opens with a new filter
DoCmd.OpenForm DocName, , , WhereClause

Also in the OnOpen Event of the Form you can replace the recordsource if you want.

Me.RecordSource = "Select * from table"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top