View Full Version : run time error '424' object required


aman
03-30-2009, 04:25 AM
Hi Guys
Can anyone please help me in sorting this error msg . This error message is coming up at CurrentDB line

Regards
AMan

Code:
Private Sub Command19_Click()Dim ssql As StringIf CheckIfEmpty(Combo12, Combo12, "Location") Then Exit SubIf CheckIfEmpty(Combo15, Combo15, "Dept") Then Exit SubIf CheckIfEmpty(Text17, Text17, "Bleeped Barcode") Then Exit SubIf CheckIfNotNumber(Text17, Text17, "Bleeped Barcode") Then Exit Subi = MsgBox("Are you sure,you want to save the record", vbYesNo + vbInformation)If i = vbYes Thenssql = "INSERT INTO inputtable (date,location,department,bleepedbarcode) VALUES ((#" & Format(TextBoxA.Value, "mm/dd/yyyy") & "#, '" & combobox12.Value & "','" & combobox15.Value & "', " & textbox17.Value & ")" CurrentDb.Execute ssql, dbFailOnError

gemma-the-husky
03-30-2009, 04:30 AM
can you resubmit this with code tags round the code please

aman
03-30-2009, 07:38 AM
Hi

Sorry,did not put the code in code tags. Here it is:

Private Sub Command19_Click()
ssql = "INSERT INTO inputtable (date,location,department,BleepedBarcode) VALUES ((#" & Text4.Value & "#, '" & Combo12.Value & "','" & Combo15.Value & "', " & Text17.Value & ")"
DoCmd.RunSQL ssql

end sub



now when i run the code then its giving me "Syntex error in Insert statement".

Could you please figure it out.
Thanks
Aman

Kiwiman
03-30-2009, 08:22 AM
Howzit

It could be the extra ( you have in the stmt

ssql = "INSERT INTO inputtable (date,location,department,BleepedBarcode) VALUES ((#" & Text4.Value & "#, '" & Combo12.Value & "','" & Combo15.Value & "', " & Text17.Value & ")"
DoCmd.RunSQL ssql



end sub

aman
03-30-2009, 08:53 AM
Hi Ya

Thanks for your reply. But when I removed that extra braket ( then it again gives the same error "Syntex error in Insert statement"

Regards
Aman

gemma-the-husky
03-30-2009, 08:57 AM
i would put extra spaces around the commas in the values bit

also if the values are numbers, they dont need to be surrounded by " characters.

numbers = no characters
text = " characters
dates = # characters

do a msgbox(ssql) first, to see what it looks like

boblarson
03-30-2009, 09:02 AM
One BIG source of your headache could be because you have used an Access Reserved Word as a field name. DATE is a Reserved Word and should not be used as a field or object name. If you have that, you MUST put it in square brackets:

ssql = "INSERT INTO inputtable ([date],location,department,BleepedBarcode)

Kiwiman
03-30-2009, 09:04 AM
Howzit

What about...



ssql = "INSERT INTO inputtable (date,location,department,BleepedBarcode) VALUES (#" & format(me.Text4,"mm-dd-yy") & "#, '" & me.Combo12. & "','" & me.Combo15. & "', " & me.Text17 & ")"
debug.print ssql
DoCmd.RunSQL ssql



if it errors, can youost what the immediate window prints for this variable.
Make sure that combo12 and 15 are text (bound column) and text17 is a value field (bound column).

aman
03-31-2009, 01:14 AM
Hi Kiwiman

Thanks for replying again.
Again its giving syntex error in insert statement. When i used immediate window then it has showen me the following line:


INSERT INTO inputtable (date,location,department,BleepedBarcode) VALUES (#03-31-09#, 'AXA Centre','ABL', 222)



Can you tell me whats wrong with this

Regards
Aman

aman
03-31-2009, 01:45 AM
Hi boblarson

Thanks so much. when i put date in brakets then it started working absolutely fine ...
cheers

JANR
03-31-2009, 01:46 AM
One BIG source of your headache could be because you have used an Access Reserved Word as a field name. DATE is a Reserved Word and should not be used as a field or object name. If you have that, you MUST put it in square brackets:

ssql = "INSERT INTO inputtable ([date],location,department,BleepedBarcode)

Se Bob's post

JR

Edit. I see you spotted the problem.