insert into problem

Stefanw

Registered User.
Local time
Today, 01:35
Joined
Jan 15, 2007
Messages
20
Hi guys,

I want a button on my form that prints data into a table. My code doesn't seem to work. Someone knows a solution?? Thanks!!


Private Sub invoice_Click()


Dim no As Integer
Dim amount As String
no = clientno.Value
amount = amount.Value

DoCmd.RunSQL ("INSERT INTO invoice ([no], [amount])" & _
"VALUES (no, amount)")

End Sub
 
One does not "print" to a table, one "updates" or "appends". Your sql indicates and append.

Just put a button on your form, then build your event on the buuton's "On Click" add your code.

Note that your SQL is not correct, it should be:
PHP:
("INSERT INTO invoice ([no], [amount])" & _
"VALUES (" me!no & ", " &  me!amount &  ))"

Me!no and Me!amount are numbers not string values.
 

Users who are viewing this thread

Back
Top Bottom