can i create message
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Can I create message boxes on a yes/no drop down menu with a mac

Can I create message boxes on a yes/no drop down menu with a mac

resolvedResolved · Urgent Priority · Version 2007

replyReply Wed 1 Dec 2010, 13:32Delegate Astley said...

Astley has attended:
Access Advanced course

Can I create message boxes on a yes/no drop down menu with a mac

Hi, Is it possible to create a macro pop-up message box on a yes/no combo drop down selection menu on ms access 2007? I've created a form titled Admin staff and a label text box entitled "Is this a tentative booking?" - when the user selects yes a pop message will be displayed and when the user selects no, again a message box will be displayed with a different message...if so, how can this be done? I've been using code in ms access 2003 which works...but when I implement the code in 2007 I receive error messages. Thanks for your clever suggestions....


Private Sub Combo1_AfterUpdate()

Dim MsgAnswer As Integer

On Error Goto Error_Handling

If Combo1.Value = "Yes" Then
MsgAnswer = MsgBox("Is this a tentative booking?", vbYesNoCancel)
If MsgAnswer = vbYes Then
'Add code to open the form
ElseIf MsgAnswer = vbNo Then
'Add code for selecting No
Else
'Cancel the operation
End If
Else
'Use the above format to code for other situations
End If

Exit Sub
Error_Handling:
MsgBox Err.Description, vbCritical

End Sub

For upcoming training course dates see: Pricing & availability

replyReply Thu 2 Dec 2010, 12:24Trainer Stephen said...

RE: Can I create message boxes on a yes/no drop down menu with a

Hi Astley
Thanks for your question

Can you tell me what the error numbers and error descriptions are. This will help me track the problem down

Thanks

Stephen

replyReply Thu 2 Dec 2010, 13:02Delegate Astley said...

RE: Can I create message boxes on a yes/no drop down menu with a

Certainly, the following message was displayed: " The expression After Update you entered as the event property setting produced the following error: Only comments may appear after End Sub, End Function, or End Property."


"This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired."


Thanks


Astley

 

Please browse our web site to find out more about
access course and other Microsoft training courses.

Access tip:

Calculating The Difference Between Dates

If you wish to calculate the time between two date fields, this can be done in a number of ways:

1. As a calculated field in a query
2. As a calculated control in a form or report
3. As a calculation in a VBA procedure.

The basic syntax to get the number of days between two dates is:

=[One Date Field] - [Another Date Field]

You can also use one of the following functions:

=Month([One Date Field] - [Another Date Field])
which calculates the number of months between the two fields

=Year([One Date Field] - [Another Date Field])
which calculates the number of years between the two fields.

Another function is the DateDiff() function.

It uses an argument to determine how the time interval is measured. For example:

=DateDiff("q",[One Date Field] - [Another Date Field])
returns the number of quarters between the two fields.

Other intervals that can be used in this expression are as follows:
"yyyy" - Years
"m" - Months
"d" - Days
"w" - Weekdays
"ww" - Weeks
"h" - Hours
"n" - Minutes
"s" - Seconds

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard