View Full Version : insert into problem


Stefanw
01-17-2007, 05:01 AM
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

llkhoutx
01-17-2007, 07:03 AM
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:
("INSERT INTO invoice ([no], [amount])" & _
"VALUES (" me!no & ", " & me!amount & ))"

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