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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO query on click of a button based on txtfields input

Status
Not open for further replies.

bluesage

Programmer
Apr 27, 2004
26
CH
here is some code i have written to add items to a table on the click of a button on a form.

===========================================

Private Sub Creerbtn_click()

Dim strSQL as string
Dim no_res as integer
Dim nom as string
dim prenom as string
dim etudiant_ouinon as string
etc..

me.resnumberscbo.value = no_res
me.nomtxt.text= nom
me.prenomtxt.text= prenom
me.etudiantlst.text= etudiant_ouinon
me.chambrenumerocbo.value = no_chambre
etc...

strSQL = "INSERT INTO residents VALUES('no_res', 'prenom', 'nom'," & _
"'no_chambre', 'etudiant_ouinon', 'admin_ouinon', 'date_naissance'," & _
"'annee_etude', 'address', 'codepostale', 'localite', 'pays')"

DoCmd.RunSQL strSQL

End Sub

===========================================

what im trying to do, is when the button is clicked:

1.) it runs the INSERT INTO query to add data to the table RESIDENTS which i have created beforehand.

2.) the values are being entered in textfields in a form, by a user.

3.) im trying to get those values from the txtboxes into the sql string so that it adds them to the table RESIDENTS.

does the code seem right?
 
Why not simply lets the wizard create for you a bounded form ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top