Simple code im derping on :P

lovett10

Registered User.
Local time
Today, 11:13
Joined
Dec 1, 2011
Messages
150
Private Sub Command24_Click()
If IsNull(Me.Text1) Then
MsgBox "You have not filled all boxes." & vbCrLf & _
"Do you want to continue?", vbYesNo, "Edit Visit Report"
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "HomePage"
End If
Dim Msg As VbMsgBoxResult
If Msg = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "HomePage"
Else
End If
End Sub

Pretty self explanatory its not working when i press yes, when it should save and open "HomePage"

Thanks for any help :)
 
maybe it is a zero length string, not a null - you can't tell, can you?

maybe

if nz(text1,"")="" then
etc

will do the trick
 
Your variable msg is not set, you need to adapt your code like this:
Code:
Private Sub Command24_Click()
   Dim Msg As VbMsgBoxResult
   If IsNull(Me.Text1) Then
      Msg = MsgBox( "You have not filled all boxes." & vbCrLf & _
               "Do you want to continue?", vbYesNo, "Edit Visit Report")
   Else
      DoCmd.RunCommand acCmdSaveRecord
      DoCmd.OpenForm "HomePage"
   End If
   If Msg = vbYes Then
      DoCmd.RunCommand acCmdSaveRecord
      DoCmd.OpenForm "HomePage"
   Else 
   End If
End Sub
 
Your variable msg is not set, you need to adapt your code like this:
Code:
Private Sub Command24_Click()
   Dim Msg As VbMsgBoxResult
   If IsNull(Me.Text1) Then
      Msg = MsgBox( "You have not filled all boxes." & vbCrLf & _
               "Do you want to continue?", vbYesNo, "Edit Visit Report")
   Else
      DoCmd.RunCommand acCmdSaveRecord
      DoCmd.OpenForm "HomePage"
   End If
   If Msg = vbYes Then
      DoCmd.RunCommand acCmdSaveRecord
      DoCmd.OpenForm "HomePage"
   Else 
   End If
End Sub

Thanks Very Much worked a treat :)
 

Users who are viewing this thread

Back
Top Bottom