Input when all values are entered

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
 
G

Guest

First things, I'd run this by stepping through it in debug. The basic
questions being a) is your initial test If DCount... coming back with a zero?
and then
b) are you getting null or blank in the fields you are testing.

A quick run through, one step at a time will give you the answer.
 
G

Guest

How do I setup the debugger to run and go thru the program?
thanks for the help

DevalilaJohn said:
First things, I'd run this by stepping through it in debug. The basic
questions being a) is your initial test If DCount... coming back with a zero?
and then
b) are you getting null or blank in the fields you are testing.

A quick run through, one step at a time will give you the answer.

pokdbz said:
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
 
G

Guest

Open the debuggin tool bar. Then click in the left margin next to where you
want to set the first breakpoint in your procedure. Keep in mind that to
start from the debugger, your procedure must take no arguements, so you might
need to set up a dummy that will call the routine you want to test.

From there clik the run sub arrow (a blue triangle pointing to the right)
which will take you to the first breakpoint. Now, click on the step into
icon to go line by line through your code. You can skip blocks of code by
setting breakpoints and hitting the run sub.

You might want to open the locals window to see the values in your current
routine.

Hope that helps

pokdbz said:
How do I setup the debugger to run and go thru the program?
thanks for the help

DevalilaJohn said:
First things, I'd run this by stepping through it in debug. The basic
questions being a) is your initial test If DCount... coming back with a zero?
and then
b) are you getting null or blank in the fields you are testing.

A quick run through, one step at a time will give you the answer.

pokdbz said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top