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!

error message after running code

Status
Not open for further replies.

bluesage

Programmer
Apr 27, 2004
26
CH

hi, i have a problem, here is the code i wrote (i left out some of the declarations) but when i run it i get an error message which says the following:

microsoft access can't append all the records in the append query.

microsoft access set 1 field(s) to Null due to a type conversion failure, and it didn't add 0 record(s) to the table due to key violations, 0 record(s) due to lock violations, and 0 record(s) due to validation rule violations.
do you want to run the action query anyway?
to ignore the error(s) and run the query, click yes...

************************************************

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.value = nom
me.prenomtxt.value = prenom
me.etudiantlst.value = 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

***************************

i don't know where i went wrong, or what the error is?

thankyou for your help
 
Here are some ideas:

1) Type conversion failure: All the values you're passing are strings. Are all the fields in the table set for text?

2) Key violations: sounds like you may have a table dependency problem? A required entry that's missing?

3) Lock violations: someone else has the record open?

4) Validation violations: a field in the table has a validation requirement that isn't being met?

< M!ke >
 
Hi...

Couple of things right off....

Dim strSQL as string
Dim no_res as integer
Dim nom as string...........Here assigned as string
dim prenom as string........SameProblem
dim etudiant_ouinon as string.....SameProblem


me.resnumberscbo.value = no_res
me.nomtxt.value = nom ...........Here assigned as a numeric
me.prenomtxt.value = prenom.......SameProblem
me.etudiantlst.value = etudiant_ouinon.....SameProblem
me.chambrenumerocbo.value = no_chambre

Are these assigment reversed ?

Should it be...
nom = me.nom.txt.Text
to give nom something to plug into the SQL statement or are you assigning something to textboxes on a form from variables?
 
what im trying to do, is when the button is clicked, it runs the INSERT INTO query to add data to the table residents which i have created beforehand.

the values are being entered in a form by a user.

so im trying to get those values form the txtboxes into the sql string so that it adds them to the table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top