By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

required textbox entry

P: n/a
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.

Apr 12 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
On 12 Apr 2006 06:51:57 -0700, fo*******@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.

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.


Apr 12 '06 #2

P: n/a
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.

Apr 12 '06 #3

P: n/a
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.

Apr 12 '06 #4

P: n/a
fo*******@martecgroup.com wrote in
news:11**********************@i39g2000cwa.googlegr oups.com:
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.


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.
Apr 13 '06 #5

P: n/a
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.

Apr 13 '06 #6

P: n/a
fo*******@martecgroup.com wrote in
news:11*********************@j33g2000cwa.googlegro ups.com:
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.

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.
Apr 13 '06 #7

P: n/a
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.

Apr 15 '06 #8

P: n/a
fo*******@martecgroup.com wrote in
news:11*********************@i40g2000cwc.googlegro ups.com:
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.

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.
Apr 15 '06 #9

P: n/a
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.

Apr 15 '06 #10

P: n/a
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.

Apr 15 '06 #11

P: n/a
fo*******@martecgroup.com wrote in
news:11**********************@t31g2000cwb.googlegr oups.com:
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.

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.
Apr 15 '06 #12

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

Apr 16 '06 #13

P: n/a
fo*******@martecgroup.com wrote in
news:11*********************@j33g2000cwa.googlegro ups.com:
I get a compile error Expected: Then or go to when I enter the
above code.

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.
Apr 16 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.