The timing of when code is run

Soma_rich

Registered User.
Local time
Yesterday, 20:32
Joined
May 2, 2007
Messages
58
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
 
save the record bore you operate on a new record

DoCmd.RunCommand AcCmdSaveRecord
 
Now I never knew that command existed thank you!
 

Users who are viewing this thread

Back
Top Bottom