help with vb code please

  • Thread starter shawna@happyharborcomics
  • Start date
S

shawna@happyharborcomics

Hi there,
sorry i'm as green as it gets for vb. I've managed to piece together the
following code in my form however I just can't manage to end the code once
the macro runs (I just need the cursor to go to the next field after user ie
presses Enter

Thanks in advance
Shawna

Private Sub Pay1_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want yadda yadda yadda?", _
vbYesNo + vbDefaultButton2) = vbYes Then
Cancel = True
DoCmd.RunMacro "changedatetime"
Cancel
End If
End Sub
 
O

Ofer

The Cancel = True make you stay in the field, so if you want the cursor to
move to the next field sfter running the code, then either set the focus to
the next field, or arange the Tab stop of each field in the right order, so
the next field after Pay1 will be the desire field

Private Sub Pay1_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want yadda yadda yadda?", _
vbYesNo + vbDefaultButton2) = vbYes Then
DoCmd.RunMacro "changedatetime"
me.nextFieldName.setfocus
End If
End Sub
 
A

Allan Murphy

Shawna

Use DoCmd.GoToControl "field name" before the end if

Field name is the name of the next field
 
S

shawna@happyharborcomics

Thanks! I really didn't understand the cancel = True correctly
 
Top