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!

How can I cast the name as a full text value? 2

Status
Not open for further replies.

mohebk

MIS
Aug 23, 2005
139
US
Hi,
I have this line of code in a module:
sqlMonth = "SELECT MIN(NumberOfMonths) as LastPostMonth FROM PCS_BUDGET_PATS_LIST GROUP BY PATNM HAVING PATNM = " & rst!PATNM

I first got an error that there is an extra comma because the actual data value in the rst!PATNM has a comma. I tried to do many things but I keep getting a syntax error no matter how I tried to cast the rst!PATNM field.

Please let me know what the correct way of trying to concatenate that field in the sql string statement.

Thanks


Mo
 
Code:
sqlMonth = "SELECT MIN(NumberOfMonths) AS LastPostMonth FROM PCS_BUDGET_PATS_LIST WHERE PATNM='" & rst!PATNM & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,
I made that change and I got another error message:

Too few parameters, expected 1.

Mo
 
Check the spelling of all field names. Place a break point in the code following this line and then open the debug window and type:
Code:
? sqlMonth
Paste the resulting SQL into the SQL view of a new blank query.

You might also find PATNM fields with single quotes. If so, try:
Code:
sqlMonth = "SELECT MIN(NumberOfMonths) AS LastPostMonth FROM PCS_BUDGET_PATS_LIST WHERE PATNM=""" & rst!PATNM & """"

Duane
Hook'D on Access
MS Access MVP
 
Does the PCS_BUDGET_PATS_LIST table really have fields named PATNM and NumberOfMonths ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Great guesses.
It was a field name error: NumberOfMonths should have been NumOfMonths.

Thanks as always.

Mo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top