Need a Quick Code Tip Please.. (1 Viewer)

Jordan76

Registered User.
Local time
Today, 15:06
Joined
Dec 26, 2002
Messages
49
Hey all,

I have 5 Text Boxes:

1: Name 1:
2: Name 2:
3: Name 3:
4: Name 4:

5: Total Number of Ninja's:


What I need to do is, I need to check if each of the first 4 text boxes (names 1 through 4) contain data, if they do, I need to add a count of 1 to the number of ninja's box. The name fields arent mandatory though, so I need to count if data has been entered, I have only found IsNull, and IsEmpty how can I test for values inside these boxes then increment the number box by 1 if they DO contain data?

Thanks for help in advance.
 

ghudson

Registered User.
Local time
Today, 10:06
Joined
Jun 8, 2002
Messages
6,195
You need to use the Not operator to test the opposite of Null. My example has five text boxes
named tbName1, tbName2, tbName3, tbName4, tbTotal.

Code:
If Not IsNull(tbName1) And Not IsNull(tbName2) And Not IsNull(tbName3) And Not IsNull(tbName4) Then
    tbTotal = tbTotal + 1
Else
    'Do nothing because tbName1 or tbName2 or tbName3 or tbName4 is empty
End If
HTH
 

Jordan76

Registered User.
Local time
Today, 15:06
Joined
Dec 26, 2002
Messages
49
Thanks!

Great! Thanks So Much,

Lastly,

Where Should I put this to test? in the Total Text box, BeforeUpdate event?

Thanks Again.
 

ghudson

Registered User.
Local time
Today, 10:06
Joined
Jun 8, 2002
Messages
6,195
It depends on what has to happen to trigger the event. For a simple test to see how my code suggestion works, just place my code in the on click event of a command button. Once you have the code working for you, you will have to decide on what (when) event you want the code to test the four text boxes to see if they all have data and then update the totals text box by a value of one. You need to be cautious as to what event triggers the testing for you do not want to update the totals text box more than once.

HTH
 

Jordan76

Registered User.
Local time
Today, 15:06
Joined
Dec 26, 2002
Messages
49
Thanks for the help, I must not be implementing it right, it doesnt work when I do. I appreciate the time though.
 

ghudson

Registered User.
Local time
Today, 10:06
Joined
Jun 8, 2002
Messages
6,195
Attached is a quick sample using my suggested code. Click the test button to see if the current record meets the condition to update the total field. Again, you will have to decide on what event you need to test the conditions and if true, update the current records total field by a value of one.

I have to call it a day so I hope that my sample points you in the right direction. Post back and I will look at it tomorrow night or maybe somebody else can jump in and assist you.

HTH
 

Attachments

  • namestest.zip
    21.7 KB · Views: 87

Users who are viewing this thread

Top Bottom