View Full Version : Pop up hint messagebox
I have a particular challenge. I'm trying to create a prompt pop up info message box that automatcally pops-up when I select a field from a drop down list/combo box. Have you any ideas how I can do this and would you have any sample code (vba for access) I can use to tackle this interesting problem? Thanks for your ideas much appreciated.:friends:
Pete
Imdabaum
08-30-2010, 02:04 PM
So you want a pop up box that displays some information based on which item you selected from the drop down?
Can you provide sample drop down options and what you may want as text in the message box?
HiTechCoach
08-30-2010, 04:01 PM
I have a particular challenge. I'm trying to create a prompt pop up info message box that automatcally pops-up when I select a field from a drop down list/combo box. Have you any ideas how I can do this and would you have any sample code (vba for access) I can use to tackle this interesting problem? Thanks for your ideas much appreciated.:friends:
Pete
Pete,
Welcome! :hi:
Terminology Note: Fields are in tables. Controls are on forms. You enter values into controls. Using the correct terminology will help you a lot when searching.
When you select a value from a combo box (drop down) box, it will fire the After Update event.
You can use the MsgBox() to display a message to the user.
Imdabaum
08-30-2010, 04:20 PM
Is this kind of what you're looking for? It's more customized message box, more because I was too lazy to write the 6 If Then statements. If you want to use the previous option and the default MessageBox, I would suggest a Select Case on the value of your dropdown box. Though you have to redo your code if you ever change drop down values. Then again if you change drop down options, you'd have to remap the tblInformant table in my example... so pick your poison.
In my defense you can create a form that manages the tables though.
Thanks for the advise! I want this message to pop up if a check box hasn't been ticked. The message will be : "Please confirm (Y/N) that an active mandate has been agreed and there an engagement letter has been agreed and signed with the client". There is a status drop downlist already designed, which you click the drop down menu will feature 'Term sheet'...when you click on the Term sheet field then the pop up option with buttons to confirm (y/n) will appear.
Thanks for your help...much appreciated:friends:
Thanks Imdabaum for your example...it's definitely given me a clear insight how to create this function :-) however the pop up form contains errors...I know once I get my head around it I will be able to experiment with a lot of tricks...do you have any clean code I could look at as an example
perserverance is the key :-)
HiTechCoach
08-31-2010, 08:17 AM
Thanks Imdabaum for your example...it's definitely given me a clear insight how to create this function :-) however the pop up form contains errors...I know once I get my head around it I will be able to experiment with a lot of tricks...do you have any clean code I could look at as an example
perserverance is the key :-)
Ran fine for me. What error are you getting?
Imdabaum
08-31-2010, 08:45 AM
Let me know what kind of errors you are getting, as everything compiles fine on my end.
You say when you click on the 'Term Sheet' field you want the button to appear. There is an On_Enter event that you can trigger when that field first gets focus, but I'm not sure that's what you are wanting.
If you want to validate before you change the value, then you'll want the Before_Update. If you want to modify something as a result of the change, then you'll want the After_Update.
Perhaps the easiest way is to design the form in the sample I sent you to appear the way you would like it.(ie: Put the checkbox where you want it) redesign the popup with the message you want displayed and I'll try to direct you on where to put the code.
That would be very straightforward for me...but I have to add this function to an existing database (dropdown list) someone else created...yes that's right! I want the user to click on the drop down list and when they click on 'term sheet' a message will pop up: "Please confirm (Y/N) that the an active mandate has been agreed and therefore an engagment letter has been agreed and signed with the client". Seems straightforward but I just can't get the message to pop up when i click...what code did you write for the pop up message to appear on your form? Thanks :-)
HiTechCoach
08-31-2010, 09:15 AM
See if the attached example is close to what you want.
Note: The database is in Access 2000 format so it can be view with Access 2000 to and later. Works with Access 2007/2010 also.
Oh, just fascinated...is there a way to create a pop-up message box with yes and no buttons on this feature? Thanks...I'm a bit rust with vba I haven't used it for 2 years so if you know of any websites or books I could search to look through similar solutions would be much appreciated.
Imdabaum
08-31-2010, 09:40 AM
...is there a way to create a pop-up message box with yes and no buttons on this feature?
Yes, it is possible.
Hit Alt+F11 to view the code for the projects, below is he syntax for the yesno buttons as you'll find in HiTechCoach's post.
MsgBox (Prompt, vbYesNo, Title)
Prompt= Message displayed to user
title = text at the top of the message box.
*Side note- When one of the buttons is clicked, it returns either vbYes or vbNo so you can use the result of the message box as validation for other items.
If Msgbox(prompt, vbYesNo, title) =vbYes Then
Msgbox("You clicked Yes")
Else
Msgbox("You clicked no")
End if
Can this code be incorporated into a pre developed drop down list on a form? for example where cbo.sheet is...is it simply a matter of changing it to status within the vba code. It's just that I would like it the functionality to appear in a ready developed drop down list. But this is great! Thanks
HiTechCoach
08-31-2010, 10:05 AM
Can this code be incorporated into a pre developed drop down list on a form? for example where cbo.sheet is...is it simply a matter of changing it to status within the vba code. It's just that I would like it the functionality to appear in a ready developed drop down list. But this is great! Thanks
The example we are giving you can be modified to do anything you need. To use the sample code, you will need to change the object's names referenced in the VBA code to match the object's names in your database.
I utilised your code for my database and I receieved this meassage: Procedure declaration does not match description of event or procedure having the same name...what do I have to do to correct this problem...so the pop up appears correctly? Thanks
HiTechCoach
08-31-2010, 11:07 AM
I utilised your code for my database and I receieved this meassage: Procedure declaration does not match description of event or procedure having the same name...what do I have to do to correct this problem...so the pop up appears correctly? Thanks
Please post your VBA code including the declare of the event procedure. This will show the name of the control.
Imdabaum
08-31-2010, 11:10 AM
Can you post the code you have written?.. err yeah what he said.
I've managed to create an information message box...but I want to achieve that when the user clicks on the drop down list a yes/no button has to be click to confirm their action
Private Sub cboSheets_AfterUpdate()
If Me.cboSheets = "Term Sheet" Then
If MsgBox("Please confirm (Y/N) that the an active mandate has been agreed and " & _
"therefore an engagment letter has been agreed and signed with the client", _
vbYesNo, "Confirm") = vbYes Then
Me.chkAgreed = True
Else
Me.chkAgreed = False
End If
Else
Me.chkAgreed = False
End If
If MsgBox(prompt, vbYesNo, Title) = vbYes Then
MsgBox ("You clicked Yes")
Else
MsgBox ("You clicked no")
End If
End Sub
Edited 1-Sep-10 by geekgirlau. Reason: insert vba tags
Imdabaum
08-31-2010, 12:53 PM
And if they click NO, would you want to perhaps undo their action?
Private Sub Status_BeforeUpdate(Cancel As Integer)
End Sub
this is the event procedure
HiTechCoach
08-31-2010, 12:54 PM
I've managed to create an information message box...but I want to achieve that when the user clicks on the drop down list a yes/no button has to be click to confirm their action
Private Sub cboSheets_AfterUpdate()
If Me.cboSheets = "Term Sheet" Then
If MsgBox("Please confirm (Y/N) that the an active mandate has been agreed and therefore an engagment letter has been agreed and signed with the client", vbYesNo, "Confirm") = vbYes Then
Me.chkAgreed = True
Else
Me.chkAgreed = False
End If
Else
Me.chkAgreed = False
End If
If MsgBox(prompt, vbYesNo, title) = vbYes Then
MsgBox ("You clicked Yes")
Else
MsgBox ("You clicked no")
End If
End Sub
Try this:
Private Sub cboSheets_AfterUpdate()
If Me.cboSheets = "Term Sheet" Then
If MsgBox("Please confirm (Y/N) that the an active mandate has been agreed and therefore an engagment letter has been agreed and signed with the client", vbYesNo, "Confirm") = vbYes Then
Me.chkAgreed = True
MsgBox ("You clicked Yes")
Else
Me.chkAgreed = False
MsgBox ("You clicked no")
End If
Else
Me.chkAgreed = False
End If
End Sub
I used a macro for the information message box but there isn't an option for a yes/no option...hence why i'm interested in writing a vba script...I add this code to a list box/combo box...the field with the drop down list is called status and the the database is called The Deal Log
I've added the code to the event procedure...when I click on the option I want nothing happens...the code is right..just not sure why it's not creating the prompt... :-S
HiTechCoach
08-31-2010, 01:26 PM
I've added the code to the event procedure...when I click on the option I want nothing happens...the code is right..just not sure why it's not creating the prompt... :-S
Again, please post the VBA code.
Imdabaum
08-31-2010, 02:11 PM
I used a macro for the information message box but there isn't an option for a yes/no option...hence why i'm interested in writing a vba script...I add this code to a list box/combo box...the field with the drop down list is called status and the the database is called The Deal Log
Unfortunately, there is no way to do a vbYesNo messagebox within a macro.
So, I realised and it seems as if it's impossible to add vba code yes/no to an existing combo box...thanks for your help I'll just create it as an alert messsage box through a macro...thanks for your assistance. :-)
thanks for your assistance
HiTechCoach
09-01-2010, 07:24 AM
... impossible to add vba code yes/no to an existing combo box...
You can everything to an existing combo box that you can add to a new one.
Imdabaum
09-01-2010, 08:40 AM
Can you please describe what you want to happen in the event they click yes, and also what will happen if they click no.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.