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

Dmax problem - Expected end of statement 1

Status
Not open for further replies.

ftook

Programmer
Dec 4, 2006
80
0
0
GB
I have the following in a normal form, coded to a button and it works fine :
me.test = DMax("[Warranty No]", "Guarantee", "[Company] = '" & Me.Company & "'") + 1

i then included the same statement into a sql update command and get "Expected end of statement" error with the "[Warranty No]" highlighted. "[Warranty No]" writing to a text value.

Any ideas please ?
 
What is the code of your SQL statement ?
Seems you have a problem with quoting ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
DoCmd.RunSQL "INSERT INTO Guarantee ( CustID, [Unit No], [Warranty No], [Start Date], [End Date], Period, [Value], [Serial No], Company ) SELECT Forms!Guarantee!Customer,DMax("[Warranty No]", "Guarantee", "[Company] = '" & Me.Company & "'") + 1, Forms!Guarantee!start, Forms!Guarantee!end, Forms!Guarantee!period, Forms!Guarantee!value, Forms!Guarantee!sno, Forms!Guarantee!Company"

dont know how to put in a code window - sorry
 
You may try this:
Code:
DoCmd.RunSQL "INSERT INTO Guarantee ( CustID, [Unit No], [Warranty No], [Start Date], [End Date], Period, [Value], [Serial No], Company ) SELECT Forms!Guarantee!Customer,DMax(""[Warranty No]"", ""Guarantee"", ""[Company] = '" & Me.Company & "'"") + 1, Forms!Guarantee!start, Forms!Guarantee!end, Forms!Guarantee!period, Forms!Guarantee!value, Forms!Guarantee!sno, Forms!Guarantee!Company"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks - worked great, i also looked up how to insert code in a monospace font.

Thanks again for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top