Textbox to Field in table

  • Thread starter Thread starter tiger
  • Start date Start date
T

tiger

Hi,

I have an access application that I am working on, I have a form with
textbox on it; I will like to store whatever the user enter in this textbox
into a field of a table. I try the following code

INSERT INTO tblEmployee (LastName) Value (Textbox)

but this is not working because I don't know how to reference to the content
of the textbox OR Is there another way to do as in using some like button
Add Record with code DoCmd.GoToRecord.

Your help is greatly Appreciated...

Thanks
Tiger
 
Assuming you're doing this in code, you'll have to build the SQL string in
code, with the value of the textbox outside of the quotes. However, since
the name is text, you'll have to ensure that its value is surrounded with
quotes as well:

Dim strSQL As String

strSQL = "INSERT INTO tblEmployee (LastName) " & _
"Value (" & Chr$(34) & Me.Textbox & Chr$(34) & ")"

CurrentDb.Execute strSQL, dbFailOnError
 

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

Back
Top