Null TextBox check

G

Guest

Good afternoon,
I'm developing an application to allow union associates in my distribution
center to bid on weeks of vacation based on contractual rules. After logging
into the application with his/her employeeID and a verifier string, the user
is shown a form with the full name and number of weeks available. I've
included textboxes that are filled in with a mod of Brendan Kidwell's
datepicker form. I don't want the user to be permitted to run the procedure
from the SUBMIT cmdbutton until all of his or her weeks are selected. (If an
associate has 4 weeks, but only completes 3 of them on the form, I want a
msgbox to let him/her know that another week needs to be selected.). So, the
problem I have is that I need to check to see if dates are entered into all
the spaces. My code doesn't seem to work, nor do I get an error message.
Can someone please help? Code below... (watch the wordwraps!)

Private Sub cmdSubmit_Click()
Dim datecheck As Date
Dim datecount As Integer
Dim nullcount As Integer
nullcount = 0
datecount = 0
datecheck = DateAdd("d", -6, Month(DLookup("[AssocDOH]", "tblAssociates",
"[AssocID#] = Forms!frmMain.txtID")) & "/" & Day(DLookup("[AssocDOH]",
"tblAssociates", "[AssocID#] = Forms!frmMain.txtID")) & "/06")
If Not Forms!frmVacEntry.txt1stweek Then nullcount = nullcount + 1
If Not Forms!frmVacEntry.txt2ndweek Then nullcount = nullcount + 1
If Not Forms!frmVacEntry.txt3rdweek Then nullcount = nullcount + 1
If Not Forms!frmVacEntry.txt4thweek Then nullcount = nullcount + 1
If Not Forms!frmVacEntry.txt5thweek Then nullcount = nullcount + 1
If nullcount > 0 Then
MsgBox "You have more weeks to use. Please complete the form",
vbOKOnly, "Try Again"
Else
If txtAddlwks = 1 Then
If datecheck < DateValue(txt1stweek) Then datecount = datecount + 1
If datecheck < DateValue(txt2ndweek) Then datecount = datecount + 1
If datecheck < DateValue(txt3rdweek) Then datecount = datecount + 1
If datecheck < DateValue(txt4thweek) Then datecount = datecount + 1
If datecheck < DateValue(txt5thweek) Then datecount = datecount + 1
If datecount = 0 Then MsgBox "You must select 1 of your weeks after
your anniversary date", vbOKOnly, "Try again"
End If
End If
End Sub
 
D

Douglas J Steele

If IsNull(Forms!frmVacEntry.txt1stweek) Then nullcount = nullcount + 1

or

If Len(Forms!frmVacEntry.txt1stweek & "") = 0 Then nullcount = nullcount + 1
 

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