When should you use Close

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I am having problems with my database
It keeps saying that I cant save records at this time and Im wondering if I
have not closed off some items or somthing.
should you use a close statement after code like this?
where should you use a closed stament?

steve - from a land downunder

SQL = "UPDATE tblSetup " & _
"SET tblSetup.SInvoiceNo = SInvoiceNo+1 " & _
"WHERE (((tblSetup.SID)=2));"
DoCmd.RunSQL SQL
 
Steve,


You have your quotes in the wrong place. Can't put a string in a numeric
field.

Try:

SQL = "UPDATE tblSetup " & _
"SET tblSetup.SInvoiceNo = " & SInvoiceNo+1 & _
"WHERE (((tblSetup.SID)=2));"

DoCmd.RunSQL SQL

'I prefer to use the Execute command.
'currentdb.execute SQL, dbfailonerror


HTH
 
He's not putting a string in a numeric field, he's putting a calculation.
The SQL is fine.

Steve: in what event are you trying to run the SQL?
 
Steve,

Doug is correct... don't listen to me.


Doug,

I thought that variables had to be outside the quotes to create the SQL. But
I had never tried an update statement like Steve has. Now I know.

Thanks for the correction.
 
Back
Top