Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a text field on the form to a table in the database

Status
Not open for further replies.

mflower

MIS
May 6, 2001
52
NZ
Does anyone have the code for saving a text field created on the form to a table in the database? The field is called txtName and the table is called Person while the field in the table is called Name. I tried the insert into Person (Name) Value (txtName) as VBA but didnt work.
 
The easiest way to do this is to bind the form to the table or a query using the form "Row Source" property. Then set the "Control Source" of txtName to "Name."

However, if this isn't possible or desirable, then you can create and execute an insert statemnt in VBA.

-----------------
Dim strSQL as string

strSQL = "Insert Into Person (Name) Value (" & txtName & ")"

DoCmd.RunSQL(strSQL)
-----------------
Terry

;-) The single biggest challenge to learning SQL programming is unlearning procedural programming. -Joe Celko

SQL Article links:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top