Inserting into a field called ' Currency' problem

Meltdown

Registered User.
Local time
Today, 23:49
Joined
Feb 25, 2002
Messages
472
Hi all,

I have a database and their is a field called 'Currency' in a table (a foreign key to a Currency table).

Access is throwing an error when I try to run an insert into this field, (probably because it's a reserved keyword).

Short of renaming the field and all the reports it's linked to, can anyone tell me how I might do an insert into the field.

Thanks
 
Do you think it might help a bit if you told us how you are currently doing the insert and what the error is?

Brian
 
Hi Brian,

It's a DoCmd.RunSQL insert. Putting the Currency field into my sql string below brings up an 'Invalid Sql' error

Code:
  sqlstr = "INSERT INTO SupportContracts" & _
        " (DetailsID2, StartDate, EndDate, Expiry, SupportContractValue, Comments, AsAgreedinContract, SupportContractCommissionPercentage, DetailsID2New)" & _
        " SELECT " & rs2("DetailsID2") & ", StartDate, EndDate, Expiry, SupportContractValue, Comments, AsAgreedinContract, SupportContractCommissionPercentage, DetailsID2New" & _
        " FROM SupportContracts WHERE SupportContractID = " & rs1("SupportContractID")

        DoCmd.RunSQL sqlstr
 
If you put a Debug.Print strSql before the RunSQL line what does the code look like?

If you think it looks allright then copy the statement to buffer and create a new query and paste the resulting sql to the query and look at it in design mode to check it for errors

David
 
OK I got this sorted, I totally forgot about bracketing the names of reserved keywords...so instead of using Currency, I use [Currency] and now it accepts the insert.

Thanks for the replies guys.

Regards
Melt
 
Thank god for using Reserved words!!!

This is one reason why you should avoid them...
 
It would also have been useful if he had posted the code in error rather than something different.

Brian
 
the trouble is sometimes its not obvious what IS a reserved word. I've tried to pass a variable called option, and I think option must be a reserved word because in

function myfunc(option as long) as boolean

the argument option is not liked by the compiler
 

Users who are viewing this thread

Back
Top Bottom