Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Option Explicit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MBoozer - 30 Nov 2005 05:16 GMT
After being about 95% complete on my application, I realized that Option
Explicit shouldl be set on all forms. I went back and did that. Thankfully I
don't have any varibales that this affected except one. The error mssg says
the "RetValue is undeclared on the first line of the following code. Any idea
on the fix? Thanks in advance.

RetValue = MsgBox("Warning:" & vbCrLf & "Editing a Supplier Name will change
the name of all existing records for that name. Do you wish to continue?",
vbExclamation + vbYesNoCancel, "Edit Suppliers")
       
       'If RetValue = 6 Then
       'Me.AllowEdits = True            'Allow Edits To Data'
       'Me.SupplierName.SetFocus          'Place cursor into FieldName'
       'ElseIf RetValue = 2 Then        'Cancel Event for Cancel Button'
       'DoCmd.CancelEvent
       'ElseIf RetValue = 7 Then        'Cancel Event For No Button'
       'DoCmd.CancelEvent
       'End If
Allen Browne - 30 Nov 2005 06:28 GMT
Open the Immediate Window (Ctrl+G), and enter:
   ? Typename(MsgBox("Continue?", vbYesNoCancel))

You will see that MsgBox() returns a Long.
Therefore you need to declare:
   Dim RetValue As Long

BTW, your might find it easier to understand your code if you use the
vbMsgBoxStyle constants, e.g.:
   If RetValue = vbYes Then ...
You can see these values if you press F2 to open the ObjectBrowser, and
search on vbYes.

The "Select Case" construct might help too:

Select Case MsgBox("Continue?", vbYesNoCancel+vbExclamation, "Edit
Suppliers")
Case vbYes
   ...
Case vbNo
   ...
Case vbCancel
   ...
End Select

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> After being about 95% complete on my application, I realized that Option
> Explicit shouldl be set on all forms. I went back and did that. Thankfully
[quoted text clipped - 18 lines]
>        'DoCmd.CancelEvent
>        'End If
MBoozer - 30 Nov 2005 07:31 GMT
Thanks Allen! Works great. Appreciate it.

> Open the Immediate Window (Ctrl+G), and enter:
>     ? Typename(MsgBox("Continue?", vbYesNoCancel))
[quoted text clipped - 43 lines]
> >        'DoCmd.CancelEvent
> >        'End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.