Hi there everyone
I have a problem with some code that does not work and I am beginning to pull my hair out, so any help would be appreciated.
The problem is on the line If Forms!F_Overall_MainMenu!IDStaff = FindTutorTxtBox Then When both numbers are the same it does not execute what I have told it to do. If for example I change the code to If Forms!F_Overall_MainMenu!IDStaff = "1" Then it works fine. The code I use is below.
Thanks in advance!
e = Nz(DLookup("LessonDate", "T_PrivatePupils_Lessons", "[ID_Contact] = Forms!F_Overall_Contacts!IDCONTACT"), "")
If Forms!F_Overall_MainMenu!EditRecordTickBox = True Then
MsgBox "You can't view another record while the current record has not been saved", vbOKOnly
Else
FindTutorTxtBox = Nz(DLookup("ToughtBy", "T_Contacts", "[IDCONTACT] = Forms!F_Overall_Contacts!IDCONTACT"), "")
FindTutorMainMenuTxtBox = Forms!F_Overall_MainMenu!IDStaff
If Forms!F_Overall_MainMenu!IDStaff = FindTutorTxtBox Then
If e = "" Then
response = MsgBox("Are you sure you want to create the first lesson for " & FirstName & " " & LastName & "?", vbQuestion + vbYesNoCancel)
If response = vbYes Then
Forms!F_Overall_MainMenu!EditRecordTickBox = True
DoCmd.OpenForm "F_PrivatePupils_NewLesson"
End If
Else
response = MsgBox("Are you sure you want to create a new lesson for " & FirstName & " " & LastName & "?", vbQuestion + vbYesNoCancel")
If response = vbYes Then
Forms!F_Overall_MainMenu!EditRecordTickBox = True
DoCmd.OpenForm "F_PrivatePupils_NewLesson"
End If
End If
Else
MsgBox "You are not the tutor for this contact", vbOKOnly
End If
End If
I have a problem with some code that does not work and I am beginning to pull my hair out, so any help would be appreciated.
The problem is on the line If Forms!F_Overall_MainMenu!IDStaff = FindTutorTxtBox Then When both numbers are the same it does not execute what I have told it to do. If for example I change the code to If Forms!F_Overall_MainMenu!IDStaff = "1" Then it works fine. The code I use is below.
Thanks in advance!
e = Nz(DLookup("LessonDate", "T_PrivatePupils_Lessons", "[ID_Contact] = Forms!F_Overall_Contacts!IDCONTACT"), "")
If Forms!F_Overall_MainMenu!EditRecordTickBox = True Then
MsgBox "You can't view another record while the current record has not been saved", vbOKOnly
Else
FindTutorTxtBox = Nz(DLookup("ToughtBy", "T_Contacts", "[IDCONTACT] = Forms!F_Overall_Contacts!IDCONTACT"), "")
FindTutorMainMenuTxtBox = Forms!F_Overall_MainMenu!IDStaff
If Forms!F_Overall_MainMenu!IDStaff = FindTutorTxtBox Then
If e = "" Then
response = MsgBox("Are you sure you want to create the first lesson for " & FirstName & " " & LastName & "?", vbQuestion + vbYesNoCancel)
If response = vbYes Then
Forms!F_Overall_MainMenu!EditRecordTickBox = True
DoCmd.OpenForm "F_PrivatePupils_NewLesson"
End If
Else
response = MsgBox("Are you sure you want to create a new lesson for " & FirstName & " " & LastName & "?", vbQuestion + vbYesNoCancel")
If response = vbYes Then
Forms!F_Overall_MainMenu!EditRecordTickBox = True
DoCmd.OpenForm "F_PrivatePupils_NewLesson"
End If
End If
Else
MsgBox "You are not the tutor for this contact", vbOKOnly
End If
End If