|
 |
access thread: prevent access message box
Message #1 by "Howard Stone" <ququmber@h...> on Tue, 18 Dec 2001 04:04:40
|
|
I have a combo box on a form with the LimitToList property set to Yes. I
wrote a code to inform the user that they have to select from the list.
After my messagebox appears Access also displays a message box.
How can I prevent Access from displaying its message box
Thanks
Message #2 by John Fejsa <John.Fejsa@h...> on Tue, 18 Dec 2001 16:23:48 +1100
|
|
Below is a sample code I use, hope it helps.
Private Sub cmbProgram_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cmbCProgram_NotInList
Dim intNewProgram As Integer
Dim lngMsgDialog As Long
Dim strProgram As String
Dim strNewProgram As String
Dim dbs As Database
Dim rst As Recordset
' Display a message box asking if the user wants to add
' a new title name.
strNewProgram =3D Me!cmbProgram.Text
strProgram =3D "Requested '" & UCase(strNewProgram) & "' Program Not
in List"
lngMsgDialog =3D vbYesNo + vbExclamation + vbDefaultButton1
Beep
intNewProgram =3D MsgBox("Do you want to add a new program?",
lngMsgDialog, strProgram)
If intNewProgram =3D vbYes Then
' Continue without displaying default error message.
Set dbs =3D CurrentDb ' Create database reference.
Set rst =3D dbs.OpenRecordset("tblPrograms", dbOpenDynaset) '
Create table reference.
rst.AddNew ' Create new record.
rst!Program =3D Me!cmbProgram.Text
rst.Update ' Save changes.
rst.Close
dbs.Close
Response =3D acDataErrAdded
Else
Response =3D acDataErrContinue
End If
Exit_cmbCProgram_NotInList:
Exit Sub
Err_cmbCProgram_NotInList:
MsgBox Error$, vbCritical, "Error Refreshing Requested Client's
Program Combobox"
Resume Exit_cmbCProgram_NotInList
End Sub
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10
WALLSEND NSW 2287
Phone: (02) 49246 336 Fax: (02) 49246 209
____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
The information contained in this email message is intended for the named
addressee only. If you are not the intended recipient you must not copy,
distribute, take any action reliant on, or disclose any details of the
information in this email to any other person or organisation. If you
have received this email in error please notify us immediately.
>>> ququmber@h... 18/12/2001 15:04:40 >>>
I have a combo box on a form with the LimitToList property set to Yes.
I
wrote a code to inform the user that they have to select from the list.
After my messagebox appears Access also displays a message box.
How can I prevent Access from displaying its message box
Thanks
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient,
please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily
the views of Hunter Health.
Message #3 by "Gregory Serrano" <SerranoG@m...> on Tue, 18 Dec 2001 15:45:49
|
|
Howard,
<< I have a combo box on a form with the LimitToList property set to Yes.
I wrote a code to inform the user that they have to select from the list.
After my messagebox appears Access also displays a message box. How can I
prevent Access from displaying its message box >>
Insert these two lines before and after your code that might produce the
Access message:
DoCmd.SetWarnings False
{Your Code Here}
DoCmd.SetWarnings True
Remember to set it back to TRUE or you'll lose ALL messages from now on!
Yikes!
Greg
|
|
 |