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

Problem with select Query 1

Status
Not open for further replies.

lcky

Programmer
Sep 29, 2005
30
GB
Hi

I am trying to select record from a table using below query. I am passing string into this query.
I am having a problem. When I run this query, I get message
"long parameter".

Please could you help me.

Dim CID as String
Dim rstCompany as Recordset

CID = "VME" <-- This String is going to be my varaible

strSQL= " SELECT Company.CompanyNo, Company.CompanyName," _
& " Company.CompanyID" _
& " FROM Company" _
& " WHERE (Company.CompanyID) Like " & CID _
& " ORDER BY Company.CompanyNo;"

Set rstCompany = dbs.OpenRecordset(strSQL)


Many thank
 
Is that the whole errormessage?

Since it is a string (text field), you'll need text delimiters (single quotes)

[tt]..." WHERE (Company.CompanyID) Like '" & CID _
& "' ORDER BY ...[/tt]

but are you also intending partial match?

[tt]..." WHERE (Company.CompanyID) Like '" & CID _
& "*' ORDER BY ...[/tt]

or

[tt]..." WHERE (Company.CompanyID) Like '*" & CID _
& "*' ORDER BY ...[/tt]

?

Also, you better disambiguate your declarations of DAO objects, as this is probably comming to bite you later on:

[tt]Dim rstCompany as DAO.Recordset[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top