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

DoCmd.OpenForm With a WhereCondition Filter

Status
Not open for further replies.

dusterb

IS-IT--Management
Jun 13, 2005
21
US
I have a Form with various fields which is used to assemble a query and return results to a list box in another "Search Results" form. The user clicks/double-clicks on a result from that Form and a vb function executes to open up yet another Form using basically this code:

strWhere = "[Company.CompanyID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="Company", WhereCondition:=strWhere

The function fails, and I'm pretty sure it is related to a data type mismatch. CompanyID is the Company table is auto-number. CompanyID is definitely available in the results listbox, and the strWhere filter is getting written properly:

[Company.CompanyID]IN ('113')

113 is the correct CompanyID coming from a click on the Results Form.

Any ideas? Thanks in advance.
 
Get rid of the single quotes:
[Company.CompanyID] IN (113)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, yikes that's embarassing. Thanks very much. I re-used some code from a similar Form where I was filtering on a string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top