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 please help

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
 
INSERT INTO has the form
Code:
INSERT INTO tablename ( fld1, fld2, fld3, ...)
            VALUES ( val1, val2, val3 )
You are missing the specification of the field names. You may also want to check to be sure that you are not duplicating unique keys or failing to supply values for fields that cannot be NULL.
 
The insert portion is pulling the right info...its just throwing that into the table is not executing
 
sksbizkit,
Please don't post the same exact question multiple times to either the same forum or multiple forums. You have another thread going in the queries forum which isn't appropriate.

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