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

SQL Statement for the Where Arg in DoCmd.OpenForm

Status
Not open for further replies.

surfside1

Programmer
Feb 12, 2006
209
US
Can someone tell me how to open a form, such as below?
How should the syntax for the WHERE arg be for the following:

Formname = frmSpendData (in current db)
Where = tablename.fieldname =
the value of the Field in frm_SpendMenu

This what I'm coding:
DoCmd.OpenForm(frmSpendData,,,(strTableName.ID=[Forms]![frm_SpendMenu.combo_Test])

Thanks!
surfside1
 
You don't have a working F1 key on your keyboard ?
help said:
DoCmd.OpenForm "Employees", , ,"LastName = 'King'"
So, for you:
DoCmd.OpenForm "frmSpendData", , ,"ID = '" & [Forms]![frm_SpendMenu]![combo_Test] & "'"

If ID is defined as numeric in the table then get rid of the single quotes.


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
When I coded a macro, which works, the OpenForm is
is frmSpendData
and the where is
[tbl_2005_Unicov]![ID]=[Forms]![frm_SpendMenu]![combo_Test]

How is the macro different and works?
Thanks PH,
Surfside1
 
and if f1, is not working, try the command button wizard.
can be very enlightening!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top