Insert Error

B

Brian Bastl

Hi all,

A2K, Dao 3.6

was looking at a problem a previous poster encountered, and I can't get it
to work either.

I've created a table with 3 fields to roughly mimmick his.
Table name = tblCurrencies
ID <PK - auto>
Currency 'text GBP, USD, EUR
Symbol 'text £, $, ?

I've set up an unbound form with 1 text control and 1 cmdbutton.

Err.Number is 3134
syntax error in "insert into...."
Where's the syntax error?
-------------------------------------------
Private Sub Command2_Click()

Dim db As Database
Dim st As String
Set db = CurrentDb

st = "INSERT INTO tblCurrencies (Currency) "
st = st & "VALUES ('" & Me.txtCurrency & "')"

db.Execute st, dbFailOnError

End Sub
----------------------------------------------

Typing ?st in the Immediate window produces:

INSERT INTO tblCurrencies (Currency) VALUES ('GBP')

This is making me nuts. I know I'm missing something.

Brian
 
M

Marshall Barton

Brian said:
A2K, Dao 3.6

was looking at a problem a previous poster encountered, and I can't get it
to work either.

I've created a table with 3 fields to roughly mimmick his.
Table name = tblCurrencies
ID <PK - auto>
Currency 'text GBP, USD, EUR
Symbol 'text £, $, ?

I've set up an unbound form with 1 text control and 1 cmdbutton.

Err.Number is 3134
syntax error in "insert into...."
Where's the syntax error?
-------------------------------------------
Private Sub Command2_Click()

Dim db As Database
Dim st As String
Set db = CurrentDb

st = "INSERT INTO tblCurrencies (Currency) "
st = st & "VALUES ('" & Me.txtCurrency & "')"

db.Execute st, dbFailOnError

End Sub
----------------------------------------------

Typing ?st in the Immediate window produces:

INSERT INTO tblCurrencies (Currency) VALUES ('GBP')


It might be because "Currency" is a reserved word for a data
type. Try changing it to something else.
 
B

Brian Bastl

Thanks Marshall,

I really feel stupid now... I wasn't even thinking about reserved words

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top