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!

INSERTING into a table

Status
Not open for further replies.

sksbizkit

Programmer
Jan 11, 2007
9
US
So i have a form with combo boxs,textboxes...and i want those values inserted in a table called "DEPENDENTS". here is the code i have, but its just not inserting the values...


Private Sub cmdAddDependent_Click()
Dim sSql As String
Dim dbThis As Database
'
Set dbThis = Access.CurrentDb


sSql = "INSERT INTO DEPENDENTS VALUES('" & cboAssociate2.Value & "','" & cboAssociate2.Value & "', '" & txtFirstName.Value & "', '" & txtLastName.Value & "', '" & txtB.Value & "'," & txtNumber.Value & ",15)"


dbThis.Execute sSql

End Sub
 
I always specify the field name in the INTO clause. Also, does DEPENDENTS allow zero length values?

Code:
sSql = "INSERT INTO DEPENDENTS ([Associate], [Assoc2],[FirstName], [LastName], [Bfld], [NumField],[NotherFld]) " & _
 VALUES('" & cboAssociate2.Value & "','" & cboAssociate2.Value & "', '" & txtFirstName.Value & "', '" & txtLastName.Value & "', '" & txtB.Value & "'," & txtNumber.Value & ",15)"

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top