473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

required textbox entry

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
13 8464
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
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
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
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
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
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
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
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
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
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
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
I get a compile error Expected: Then or go to when I enter the above
code.

Apr 16 '06 #13
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ian | last post by:
Using Access 97 I have a form with several text boxes, I am trying to get each text box to display the word "Required" for the appropriate boxes on a new record. A friend gave me the following line...
3
by: Orchid | last post by:
Hello All, Hope someone can help me on my required field problems. I have a form base on a table for users to input new Employees. There are 4 fields that cannot be Null when entering new...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
2
by: Paul | last post by:
I have a user that when tabs to a textbox notices that the curser lines up with the end of the current text entry if the textbox is in the multiline mode. If the textbox is in the single line mode...
0
by: EgoSum | last post by:
Can someone help me with custom text box? I want change behavior custom date text box - disallow entry and pass entry from numeric keyboard to a text box. Code below disallow entry, but how I can...
2
by: EgoSum | last post by:
Can someone help me with custom text box? I want change behavior custom date text box - disallow entry and pass entry from numeric keyboard to a text box. Code below disallow entry, but how I can...
2
by: cephal0n | last post by:
I have this peroblem thats really bugging me for days, please have a patience to read it and help me find the probplem because I knew I missed it and just cant tell where. I have a table named...
3
by: =?iso-8859-1?Q?Johnny_J=F6rgensen?= | last post by:
I've got a textbox where I filter the input in the KeyPress event to allow only certain characters. However, If the user cuts and pastes a text into the textbox, all text is entered - not only...
2
by: akshalika | last post by:
Hi, I have a repeater control. it dynamically bind textbox or dropdown base on some condition. i want to bind required field validator dynamically for validate textbox or dropdown. here is my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.