I have a bit of code that uses a froms JobNumber (which is an autonumber from a table) and uses it to append some informatin to the same table.
My question is, when does the autonumber shown in a form appear in the table. If I use my code as it is now when it pick ups the jobnumbe it is not yet in the table. So it errors.
If I go to design view then back to form view the job number is present in the table and the code works (I dont think their is a way to go to design view in VB, is there?)
Here is my codes please help as this is driving my mad!
Private Sub FinishCylicInput_Click()
Dim randpass As Double
Dim formJobNumber As Integer
Randomize
randpass = Int((999999 - 100000 + 1) * Rnd + 100000)
formJobNumber = Forms![CyclicJobInput].JobNumber
DoCmd.RunSQL "UPDATE JobDetails SET password =" & randpass & " where JobDetails.jobnumber =" & formJobNumber & ";"
End Sub
My question is, when does the autonumber shown in a form appear in the table. If I use my code as it is now when it pick ups the jobnumbe it is not yet in the table. So it errors.
If I go to design view then back to form view the job number is present in the table and the code works (I dont think their is a way to go to design view in VB, is there?)
Here is my codes please help as this is driving my mad!
Private Sub FinishCylicInput_Click()
Dim randpass As Double
Dim formJobNumber As Integer
Randomize
randpass = Int((999999 - 100000 + 1) * Rnd + 100000)
formJobNumber = Forms![CyclicJobInput].JobNumber
DoCmd.RunSQL "UPDATE JobDetails SET password =" & randpass & " where JobDetails.jobnumber =" & formJobNumber & ";"
End Sub