G
Guest
I have code below. What I want it to do is when all of the information is
entered to put it into the table and display the subject number. When
something is missing I want it to display a message that something is missing
and not input the values into the fields untill all of the text boxes are
entered. What it is doing is when I skip a text box it just inputs the
values in anyway and clears all of the text boxes.
Here is the code that I have so far.
Thanks
Randomize
RandomNum = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
If DCount("[geneticIDnumber]", "[Patient_Registry]", "[geneticIDnumber]=" &
RandomNum) = 0 Then
If Nz(Me.FirstName.Value, 0) = 0 Then
MsgBox ("First name can't be blank")
ElseIf Nz(Me.LastName.Value, 0) = 0 Then
MsgBox ("Last name can't be blank")
ElseIf Nz(Me.BirthDate.Value, 0) = 0 Then
MsgBox ("Birth Date can't be blank")
ElseIf Nz(Me.Race.Value, 0) = 0 Then
MsgBox ("Race can't be blank")
ElseIf Nz(Me.Hispanic.Value, 0) = 0 Then
MsgBox ("Hispanic can't be blank")
ElseIf Nz(Me.ConsentDate.Value, 0) = 0 Then
MsgBox ("Consent Date can't be blank")
ElseIf Nz(Me.BloodDate.Value, 0) = 0 Then
MsgBox ("Blood Draw Date can't be blank")
ElseIf Nz(Me.StudyTitle.Value, 0) = 0 Then
MsgBox ("Study Title can't be blank")
ElseIf Nz(Me.LongTermConsent.Value, 0) = 0 Then
MsgBox ("Long Term Consent can't be blank")
End If
Me.geneticIDnumber = RandomNum
End If
MsgBox ("Subject number: " & subjectnum.Value & "")
DoCmd.GoToRecord , , acNewRec
entered to put it into the table and display the subject number. When
something is missing I want it to display a message that something is missing
and not input the values into the fields untill all of the text boxes are
entered. What it is doing is when I skip a text box it just inputs the
values in anyway and clears all of the text boxes.
Here is the code that I have so far.
Thanks
Randomize
RandomNum = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
If DCount("[geneticIDnumber]", "[Patient_Registry]", "[geneticIDnumber]=" &
RandomNum) = 0 Then
If Nz(Me.FirstName.Value, 0) = 0 Then
MsgBox ("First name can't be blank")
ElseIf Nz(Me.LastName.Value, 0) = 0 Then
MsgBox ("Last name can't be blank")
ElseIf Nz(Me.BirthDate.Value, 0) = 0 Then
MsgBox ("Birth Date can't be blank")
ElseIf Nz(Me.Race.Value, 0) = 0 Then
MsgBox ("Race can't be blank")
ElseIf Nz(Me.Hispanic.Value, 0) = 0 Then
MsgBox ("Hispanic can't be blank")
ElseIf Nz(Me.ConsentDate.Value, 0) = 0 Then
MsgBox ("Consent Date can't be blank")
ElseIf Nz(Me.BloodDate.Value, 0) = 0 Then
MsgBox ("Blood Draw Date can't be blank")
ElseIf Nz(Me.StudyTitle.Value, 0) = 0 Then
MsgBox ("Study Title can't be blank")
ElseIf Nz(Me.LongTermConsent.Value, 0) = 0 Then
MsgBox ("Long Term Consent can't be blank")
End If
Me.geneticIDnumber = RandomNum
End If
MsgBox ("Subject number: " & subjectnum.Value & "")
DoCmd.GoToRecord , , acNewRec