I'm trying to realise a simple sign up structure, and I am really new in VBA
and Access
.
At the instruction INSERT TO
it should add a record to the table USER. but it adds 2 identical records that have just a different userID, generated by the Automatic Numeration. Then I want to copy the last generated UserID in global variable valID, so that I can insert this UserID in a another table.
What am I doing wrong?
DoCmd.RunSQL ("INSERT INTO User ([Type], [FiscalCode], [Name], [Surname], [Birthdate], [Gender], [phoneNumber], [email], [country], [city], [postalCode], [street], [houseNumber])VALUES ('" & valtype & "', '" & valfis & "', '" & valname & "', '" & valsur & "', '" & valdata & "', '" & valgen & "', '" & valphone & "', '" & valemail & "','" & valcountry & "', '" & valcity & "', '" & valcode & "', '" & valstreet & "', " & valnum & ")")
valID = DLookup("[UserID]", "User", "[FiscalCode] = '" & valfis & "'")
after this code I want to do another instruction of the type insert to in a different table to insert in this new table as primary key the UserId I just obtained. this is the only other INSERT INTO inside the code.