all groups > sql server programming > june 2006 >
You're in the

sql server programming

group:

VBA Access Insert New


VBA Access Insert New jason.teen NO[at]SPAM gmail.com
6/12/2006 7:24:05 PM
sql server programming:
Hi,

I'm making a form which simply just has one textbox and one button.
When you type a name into the textbox and hit insert its suppose to add
a new record to the "Name" Table.

Here is what I have in my VBA code below:

Private Sub btnInsert_Click()
Dim strSQL As String

strSQL = "INSERT INTO Name ([FirstName]) Values (" &
Me.txtName.Value & ")"

CurrentDb.Execute (strSQL)
End Sub


ERROR MSG = Run Time Error 3061: Too few parameters. expected 1 on the
line with "CurrentDb.Execute (strSQL)" and clearly you can see there is
one parament in there!!!

If anyone has any ideas...please post.

Thanks
RE: VBA Access Insert New rb
6/13/2006 1:49:01 AM
You need to enclose the text you are inserting in single inverted commas:

strSQL = "INSERT INTO Name ([FirstName]) Values ('" & Me.txtName.Value & "')"

Ray

[quoted text, click to view]
AddThis Social Bookmark Button