473,670 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiot ics.SetFocus
End If
End Sub

Kenny G
Nov 12 '05 #1
6 3772
"Kenny G" <kg****@hotmail .com> wrote in message
news:81******** *************** ***@posting.goo gle.com...
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.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiot ics.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.oralantibiot ics.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.TypeOfSurger y = "Colon Surgery" And Me.Dirty = True Then
If Me.OralAntibiot ics <> "Y" Or Me.OralAntibiot ics <> "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.goo gle.com...
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.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiot ics.SetFocus
End If
End Sub

Kenny G

Nov 12 '05 #3
kg****@hotmail. com (Kenny G) wrote in
news:81******** *************** ***@posting.goo gle.com:
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.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiot ics.SetFocus
End If
End Sub

Kenny G


The me.OralAntibiot ics.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****@ThisPar tNotVailid.wave .co.nz> wrote in message news:<bs******* ***@news.wave.c o.nz>...
Remove the second part of the If statement which calls the msgbox call and
the me.oralantibiot ics.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.TypeOfSurger y = "Colon Surgery" And Me.Dirty = True Then
If Me.OralAntibiot ics <> "Y" Or Me.OralAntibiot ics <> "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.goo gle.com...
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.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
Me.OralAntibiot ics.SetFocus
End If
End Sub

Kenny G

Nov 12 '05 #5
Is the "TypeOfSurg ery" 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.TypeOfSurger y.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.goo gle.com...
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 "TypeOfSurg ery" 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 "AntibioticAlle rgy".

After some work this weekend here is the answer.

There were two Procedures built:

One on enter:

Private Sub Oral Antibiotics_Ent er()
If Me.TypeofSurger y <> "Colon Surgery" Then
DoCmd.GoToContr ol "AntibioticAlle rgy"
End If
End Sub

The second on exit:

Private Sub Oral Antibiotics_Exi t(Cancel As Integer)
If Me.TypeofSurger y ="Colon Surgery" Then
If IsNull(Me.OralA ntibiotics) 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****@ThisPar tNotVailid.wave .co.nz> wrote in message news:<bs******* ***@news.wave.c o.nz>...
Is the "TypeOfSurg ery" 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.TypeOfSurger y.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.goo gle.com...
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
3850
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 = Conn.Execute("select rut from encuestarutaparaiso where rut='" & rut_usuario & "'") if not rs.eof then msgbox "Gracias por tu interes pera ya has respondido esta encuesta" end if Set rs= Conn.Execute("Select * from tabladatos where rut = '" &...
6
5065
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
14115
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 rejected. A supervisor opens frmVacationWeeks and either approves or rejects dates the employee has requested for vacation. When the supervisor closes frmVacationWeeks, if he has failed to click a checkbox to approve or reject a date, I want a...
8
784
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 work with an API function?
12
4998
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
1466
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
1598
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
3421
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 numbers only" style = MsgBoxStyle.OkOnly title = "ERROR in cast"
2
4851
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 use radio buttons). How it works... Pre-1) File consists of the following format: Question 1 Choice 1
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.