Connecting Tech Pros Worldwide Forums | Help | Site Map

required textbox entry

fong.yang@martecgroup.com
Guest
 
Posts: n/a
#1: Apr 12 '06
I have a combo box with different types of business listed. If a user
selects "Other" from the combo box list I want to make so that the user
is required to make an entry in a textbox on the form. Also is there a
way to make just certain textboxes on the form required fields and if
they are skipped to display a message like " HoursOfOperation is a
required field" move the user to each required field for input? Thanks.


Tom van Stiphout
Guest
 
Posts: n/a
#2: Apr 12 '06

re: required textbox entry


On 12 Apr 2006 06:51:57 -0700, fong.yang@martecgroup.com wrote:

This type of validation can best be done in the Form_BeforeUpdate
event:
if cbo1.Value = "Other" and txt2.Value Is Null then
Msgbox "Yo! Fill out the form!"
txt2.SetFocus
Cancel = True 'Important; this stops the record from being saved.
end if

-Tom.

[color=blue]
>I have a combo box with different types of business listed. If a user
>selects "Other" from the combo box list I want to make so that the user
>is required to make an entry in a textbox on the form. Also is there a
>way to make just certain textboxes on the form required fields and if
>they are skipped to display a message like " HoursOfOperation is a
>required field" move the user to each required field for input? Thanks.[/color]

fong.yang@martecgroup.com
Guest
 
Posts: n/a
#3: Apr 12 '06

re: required textbox entry


I have the following to time stamp changes made to the record

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!UpdatedOn = Now()
End Sub

Can I have the time stamp as well as the above validation both in the
form's before update event?

Thanks.

fong.yang@martecgroup.com
Guest
 
Posts: n/a
#4: Apr 12 '06

re: required textbox entry


I have the following to time stamp changes made to the record

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!UpdatedOn = Now()
End Sub

Can I have the time stamp as well as the above validation both in the
form's before update event?

Thanks.

Bob Quintal
Guest
 
Posts: n/a
#5: Apr 13 '06

re: required textbox entry


fong.yang@martecgroup.com wrote in
news:1144853162.271208.175680@i39g2000cwa.googlegr oups.com:
[color=blue]
> I have the following to time stamp changes made to the record
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> Me!UpdatedOn = Now()
> End Sub
>
> Can I have the time stamp as well as the above validation both
> in the form's before update event?
>
> Thanks.
>[/color]

Yes you can. Just add Mr van Stiphout's code after the existing
statement and before the end sub.

--
Bob Quintal

PA is y I've altered my email address.
fong.yang@martecgroup.com
Guest
 
Posts: n/a
#6: Apr 13 '06

re: required textbox entry


the before event now looks like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!UpdatedOn = Now()
If PrimaryBusiness.Value = "Other" And PrimaryOther.Value Is Null Then
MsgBox "Must enter type of business!!"
PrimaryOther.SetFocus
Cancel = True 'Important; this stops the record from being saved.
End If
End Sub

When I try to run it I get a runtime error '424' Object required. What
does that mean? How do I get it to work? Thanks.

Bob Quintal
Guest
 
Posts: n/a
#7: Apr 13 '06

re: required textbox entry


fong.yang@martecgroup.com wrote in
news:1144932066.722687.77790@j33g2000cwa.googlegro ups.com:
[color=blue]
> the before event now looks like this:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> Me!UpdatedOn = Now()
> If PrimaryBusiness.Value = "Other" And PrimaryOther.Value Is
> Null Then
> MsgBox "Must enter type of business!!"
> PrimaryOther.SetFocus
> Cancel = True 'Important; this stops the record from being
> saved.
> End If
> End Sub
>
> When I try to run it I get a runtime error '424' Object
> required. What does that mean? How do I get it to work?
> Thanks.
>[/color]
Use this instead

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!UpdatedOn = Now()
If Me!PrimaryBusiness.Value = "Other" _
And isnull(Me!PrimaryOther.Value) Then
MsgBox "Must enter type of business!!"
Me!PrimaryOther.SetFocus
Cancel = True 'Important; this stops the record from being
saved.
End If
End Sub

the Me! qualifiers were missing and isnull() works when
sometimes is null does not.

--
Bob Quintal

PA is y I've altered my email address.
fong.yang@martecgroup.com
Guest
 
Posts: n/a
#8: Apr 15 '06

re: required textbox entry


I have four textbox listed on the form(DaysOfOperation, HoursStart,
HoursFinish, PrimaryOther) along with one combo box (Primary Business).
I want all of the them to require an entry before moving on to the
next record. This is what I have so far in the Before Update event of
the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!UpdatedOn = Now()
If Me!PrimaryBusiness.Value = "Other" _
And IsNull(Me!PrimaryOther.Value) Then
MsgBox "Must Enter Type Of Business!!"
Me!PrimaryOther.SetFocus
Cancel = True 'Important; this stops the record from being saved.
End If
End Sub

This works to require an entry in PrimaryOther, but it still allows the
other 3 textboxes to be blank. How can I get the other 3 to be
required as well. Thanks.

Bob Quintal
Guest
 
Posts: n/a
#9: Apr 15 '06

re: required textbox entry


fong.yang@martecgroup.com wrote in
news:1145123085.841185.66550@i40g2000cwc.googlegro ups.com:
[color=blue]
> I have four textbox listed on the form(DaysOfOperation,
> HoursStart, HoursFinish, PrimaryOther) along with one combo
> box (Primary Business).
> I want all of the them to require an entry before moving on
> to the
> next record. This is what I have so far in the Before Update
> event of the form:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> Me!UpdatedOn = Now()
> If Me!PrimaryBusiness.Value = "Other" _
> And IsNull(Me!PrimaryOther.Value) Then
> MsgBox "Must Enter Type Of Business!!"
> Me!PrimaryOther.SetFocus
> Cancel = True 'Important; this stops the record from being
> saved.
> End If
> End Sub
>
> This works to require an entry in PrimaryOther, but it still
> allows the other 3 textboxes to be blank. How can I get the
> other 3 to be required as well. Thanks.
>[/color]
just add three similar tests (one for each field.
The second would be

If IsNull(Me!DaysOfOperation.Value) Then
MsgBox "Must Enter Days of operation!!"
Me!DaysOfOperation.SetFocus
Cancel = True
End If

The next test would start....
If IsNull(Me!HoursStart.Value) Then
.......
......

You can figure them out.




--
Bob Quintal

PA is y I've altered my email address.
fong.yang@martecgroup.com
Guest
 
Posts: n/a
#10: Apr 15 '06

re: required textbox entry


I've added the three tests. Still the only one that is working as a
required field is just PrimaryOther. The other three textboxes can
still be left blank. The three textboxes are just textboxes. They are
not part of any combo boxes or anything. Thanks.

fong.yang@martecgroup.com
Guest
 
Posts: n/a
#11: Apr 15 '06

re: required textbox entry


I've added the three tests. Still the only one that is working as a
required field is just PrimaryOther. The other three textboxes can
still be left blank. The three textboxes are just textboxes. They are
not part of any combo boxes or anything. Thanks.

Bob Quintal
Guest
 
Posts: n/a
#12: Apr 16 '06

re: required textbox entry


fong.yang@martecgroup.com wrote in
news:1145140390.735011.256570@t31g2000cwb.googlegr oups.com:
[color=blue]
> I've added the three tests. Still the only one that is
> working as a required field is just PrimaryOther. The other
> three textboxes can still be left blank. The three textboxes
> are just textboxes. They are not part of any combo boxes or
> anything. Thanks.
>[/color]
instead of
If IsNull(Me!DaysOfOperation.Value) Then

try
If len(me!daysofoperation & "") = 0

MsgBox "Must Enter Days of operation!!"
Me!DaysOfOperation.SetFocus
Cancel = True
End If

--
Bob Quintal

PA is y I've altered my email address.
fong.yang@martecgroup.com
Guest
 
Posts: n/a
#13: Apr 16 '06

re: required textbox entry


I get a compile error Expected: Then or go to when I enter the above
code.

Bob Quintal
Guest
 
Posts: n/a
#14: Apr 16 '06

re: required textbox entry


fong.yang@martecgroup.com wrote in
news:1145145924.465741.10280@j33g2000cwa.googlegro ups.com:
[color=blue]
> I get a compile error Expected: Then or go to when I enter the
> above code.
>[/color]
If len(me!daysofoperation & "") = 0 THEN

Please try to set your newsreader to quote what you are replying
to.


--
Bob Quintal

PA is y I've altered my email address.
Closed Thread