SQL with variable from form

I

info

Hi,

I should like to use the following code by opening of a report.

sql = "AREA in (" & "'501'" & "," & "'502'" & ","
& "'503'" & "," & "'133'" & "," & "'134'" & ")"

Only with the 501, 502, 503, 133 and 134 from out a combobox from the form.
Area 1 up to and including 5, but it seems not to be working by me?

Frank
 
R

RobFMS

1. Is Area a text field or a numeric field?
2. Are you using the "WhereCondition" of the DoCmd.OpenReport?

Example

SQL = "Area In (501, 502, 503, 133, 134)" ' Numeric version
DoCmd.OpenReport ReportName:="frmReport", WhereCondition:=SQL

SQL = "Area In ('501', '502', '503', '133', '134')" ' text version
DoCmd.OpenReport ReportName:="frmReport", WhereCondition:=SQL

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top