473,378 Members | 1,536 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,378 software developers and data experts.

MsgBox won't close.

Reference the below sub: I can't get the message box to close and
therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.

Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiotics.SetFocus
End If
End Sub

Kenny G
Nov 12 '05 #1
6 3730
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om...
Reference the below sub: I can't get the message box to close and
therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.

Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiotics.SetFocus
End If
End Sub


A MsgBox has to be closed by the user. If you want something that closes
automatically you can use your own form instead.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #2
Remove the second part of the If statement which calls the msgbox call and
the me.oralantibiotics.setfocus.
On the form (if there is some room) use the label control and write "Enter a
Y or N" next to the field, don't use the field's label but create a new
label. Then on the field's OnExit event place the following code to prevent
the user from leaving the field without entering data.

Private Sub OralAntibiotics_Exit(Cancel As Integer)
If Me.TypeOfSurgery = "Colon Surgery" And Me.Dirty = True Then
If Me.OralAntibiotics <> "Y" Or Me.OralAntibiotics <> "N" Then
MsgBox "Data Entry Is Required - Enter a Y or an N!", vbCritical
Cancel = True
End If
End If
End Sub

This checks if the type of surgery is Colon and the form is dirty (that the
current record is being edited). Then it checks if a Y or a N has been
enterd into the field and prompts the user to enter the correct data. The
Cancel = True prevents the user from leaving the field until the correct
data has been entered.

Stewart
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om...
Reference the below sub: I can't get the message box to close and
therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.

Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiotics.SetFocus
End If
End Sub

Kenny G

Nov 12 '05 #3
kg****@hotmail.com (Kenny G) wrote in
news:81**************************@posting.google.c om:
Reference the below sub: I can't get the message box to close
and therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.

Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiotics.SetFocus
End If
End Sub

Kenny G


The me.OralAntibiotics.Setfocus is triggering the sub
OralAntibiotics_Enter(), which opens a new messagebox. It happens
so fast that you think that the messagebox never closes.

Bob Q

Nov 12 '05 #4
Thanks for your response, the code and your good explaination of that
code seem to make sense. I entered the code and if Colon Surgery is
selected I am still not prompted for a Y or N response in
OralAntibiotics.

Kenny G

"Stewart Allen" <sa****@ThisPartNotVailid.wave.co.nz> wrote in message news:<bs**********@news.wave.co.nz>...
Remove the second part of the If statement which calls the msgbox call and
the me.oralantibiotics.setfocus.
On the form (if there is some room) use the label control and write "Enter a
Y or N" next to the field, don't use the field's label but create a new
label. Then on the field's OnExit event place the following code to prevent
the user from leaving the field without entering data.

Private Sub OralAntibiotics_Exit(Cancel As Integer)
If Me.TypeOfSurgery = "Colon Surgery" And Me.Dirty = True Then
If Me.OralAntibiotics <> "Y" Or Me.OralAntibiotics <> "N" Then
MsgBox "Data Entry Is Required - Enter a Y or an N!", vbCritical
Cancel = True
End If
End If
End Sub

This checks if the type of surgery is Colon and the form is dirty (that the
current record is being edited). Then it checks if a Y or a N has been
enterd into the field and prompts the user to enter the correct data. The
Cancel = True prevents the user from leaving the field until the correct
data has been entered.

Stewart
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om...
Reference the below sub: I can't get the message box to close and
therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.

Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiotics.SetFocus
End If
End Sub

Kenny G

Nov 12 '05 #5
Is the "TypeOfSurgery" control on the form a combo box where the rowsource
for the combo box from a another table?
If it is, does each surgery type have its own ID number so its only the
number being stored in the main table so the combo box's recordsouce has 2
columns, SureryTypeID and SurgeryType where the SurgeryTypeID is bound to
the main table with the column widths set at 0cm; 3cm hiding the first
column?

If the control on the form is a combo box pulled from a table as above
change the code to:

If Me.TypeOfSurgery.Column(1) = "Colon Surgery" And Me.Dirty = True Then

This will read the second column of the combo box and not the first.

Please post back if this doesn't work or you're using some other method to
store the data.

Stewart
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om...
Thanks for your response, the code and your good explaination of that
code seem to make sense. I entered the code and if Colon Surgery is
selected I am still not prompted for a Y or N response in
OralAntibiotics.

Kenny G

Nov 12 '05 #6
With regard to your question: Is the "TypeOfSurgery" control on the
form a combo box where the rowsource for the combo box from a another
table?

No, the display control: is a combo box
row source type: Value List
row source: Cardiac Surgery, Colon Surgery, Hip Replacement
etc.
bound column 1
column count 1

What I wanted to accomplish is this: If the TypeofSurgery is Colon
Surgery, I wanted the OralAntibiotics to have either a Y or N in that
field.

If other than Colon Surgery, the cursor would move to the next
appropriate field, that being "AntibioticAllergy".

After some work this weekend here is the answer.

There were two Procedures built:

One on enter:

Private Sub Oral Antibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
End If
End Sub

The second on exit:

Private Sub Oral Antibiotics_Exit(Cancel As Integer)
If Me.TypeofSurgery ="Colon Surgery" Then
If IsNull(Me.OralAntibiotics) Then
MsgBox "Data Entry Required - Enter a Y or an N!"
Cancel = True
End If
End If
End Sub

I certainly appreciate everyone's help on this just being able to
discuss this with someone and coming back fresh after awhile made a
lot of difference.
Stewart your code gave me the idea of breaking this action into two
procedures, a special thanks to you as well.

Kenny G


"Stewart Allen" <sa****@ThisPartNotVailid.wave.co.nz> wrote in message news:<bs**********@news.wave.co.nz>...
Is the "TypeOfSurgery" control on the form a combo box where the rowsource
for the combo box from a another table?
If it is, does each surgery type have its own ID number so its only the
number being stored in the main table so the combo box's recordsouce has 2
columns, SureryTypeID and SurgeryType where the SurgeryTypeID is bound to
the main table with the column widths set at 0cm; 3cm hiding the first
column?

If the control on the form is a combo box pulled from a table as above
change the code to:

If Me.TypeOfSurgery.Column(1) = "Colon Surgery" And Me.Dirty = True Then

This will read the second column of the combo box and not the first.

Please post back if this doesn't work or you're using some other method to
store the data.

Stewart
"Kenny G" <kg****@hotmail.com> wrote in message
news:81**************************@posting.google.c om...
Thanks for your response, the code and your good explaination of that
code seem to make sense. I entered the code and if Colon Surgery is
selected I am still not prompted for a Y or N response in
OralAntibiotics.

Kenny G

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lakrom | last post by:
Hi to all, how to put msgbox in this asp page, this send me a message Denied permission: 'MsgBox' <% Set Conn=server.createobject("ADODB.connection") Conn.open application("StrConRuta") set rs =...
6
by: Lapchien | last post by:
In this bit of code provided so helpfully by Nath: Private Sub Command118_Click() Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.openrecordset("IMPORT")
17
by: jdph40 | last post by:
Question 1: In Access 97, I have a form (frmVacationWeeks) with a subform (sbfrmPostVacDates). The subform can have up to 33 records and each record has 2 checkboxes, one for approved and one for...
8
by: deko | last post by:
Can I close a MsgBox with VBA Code? Something like: If IsOpen (MsgBox, "Title") Then Close(MsgBox, "Title") Run some code Else Run other code End If Can this be done in VBA? Do I need to...
12
by: bokiteam | last post by:
Hi All, I dont' know why I can not pop up a message box. MsgBox("test") it is ok in vb6... Best regards, Boki.
2
by: John Wright | last post by:
How can I close a msgbox programtically. I have a process that can run 24/7. If an operator is not at the station, I want to close the msgbox that appears. How can I do this? John
4
by: James | last post by:
What does this mean? 'To specify more than the first argument, you must use the MsgBox function in an expression' I'd love to see an example. Thanks!
9
by: Ivan Jericevich | last post by:
In my code below at the line 'response' a blip sound is heard and the program exits the sub -- No MsgBox is displayed. What am I doing wrong? If nonNumberEntered = True Then msg = "Enter...
2
by: perkykoala | last post by:
I apologize in advance for being REALLY detailed/verbose. It's the result of staring/tweaking code for too long. Using VB 2005: I need to design a multiple choice test (unfortunately, I can't...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.