vba sql update statement - can't get the format() syntax right

rincewind_wizzard

Registered User.
Local time
Today, 23:11
Joined
Feb 7, 2018
Messages
23
Hi all,

I'm trying to run the following in a module, but it doesn't like the 0000000 (I get expected: end of statement). The employee number field is text and I need to pad it with leading zeros.

'Tidy up the pay number in the tax and NI table - format to 7 places
strsql = "UPDATE tblIMPORT_NIable_Taxable_Earnings SET tblIMPORT_NIable_Taxable_Earnings.[Employee number] = Format([Employee number],"0000000");"

DoCmd.RunSQL strsql


Yours,
Paul
 
You could try:
Code:
strsql = "UPDATE tblIMPORT_NIable_Taxable_Earnings SET tblIMPORT_NIable_Taxable_Earnings.[Employee number] = '" & Format([Employee number],"0000000") & "';"
Hope that helps...
 
Out of curiosity, what datatype is field [Employee number] ?
 
You could try:
Code:
strsql = "UPDATE tblIMPORT_NIable_Taxable_Earnings SET tblIMPORT_NIable_Taxable_Earnings.[Employee number] = '" & Format([Employee number],"0000000") & "';"
Hope that helps...
On second thought, maybe more like this?
Code:
strsql = "UPDATE tblIMPORT_NIable_Taxable_Earnings SET tblIMPORT_NIable_Taxable_Earnings.[Employee number] = Format([Employee number],""0000000"");"
 
On second thought, maybe more like this?
Code:
strsql = "UPDATE tblIMPORT_NIable_Taxable_Earnings SET tblIMPORT_NIable_Taxable_Earnings.[Employee number] = Format([Employee number],""0000000"");"
Wonderful. Works fine. I thought I'd tried the extra quotes, must be imagining it.
Thanks
 
I'd be interested to know if the first option worked?
The one with the concatenation?
 

Users who are viewing this thread

Back
Top Bottom