Pop up form

Nej

New member
Local time
Today, 17:42
Joined
Jul 15, 2002
Messages
8
Hello. I am new to Access so any help or point in the right direction would be greatly appriciated.

In my main swithboard(which was set up using Switchboard page comes up with 5 buttons that all run seperate queries. What I would like to do is, when the user clicks on a button to run a query, a pop up form will display and say something like, "Are you sure you want to run this query?" And the form will have the options "Yes" and "No". If the user clicks "Yes" the query is run and the query isn't run if the user clicks on "No."

Also, if the query is ran I want it to let the user know the query was run sucessfully with another pop up form saying "The 'querynamehere' query has run sucessfully".

Is there a way to do this while using the Swithboard Manager? I do know some code but not very much since I'm just starting out.

Thank you for any help in advance.
 
I think that you should look into the MsgBox function.
 
That is what I started off doing actually. The database that I'm working on was created by someone else and they originally made macros to run the query. And they used the message box function in the macro. But the message box saying "The query was run successfully" ran every time even if the user clicked cancel on the default Access message that asks if you want to run the query or not.

I couldn't figure out how to switch the macro conditional fields to allow the message box to pop up only if they clicked on "yes" on the default Access message box. So then I converted the macros into VBA code and tried to do it there but was also unsuccessful.

Thats when I asked for advice here at work and was told to try and make a form pop up that asks to run the query instead of using a macro or message box. But the person who gave me the suggestion didn't know exactly how to do that either. So thats when I posted the question here.

Here is some code I started making in the converted macro but since I don't know much coding yet it didn't work.

Function mcrUpdateToolHist1()
On Error GoTo mcrUpdateToolHist1_Err
RetValue = MsgBox("Click OK to run Query.", vbOKCancel)
If RetValue = -1 (I'm not sure what value to put in here) Then
DoCmd.OpenQuery "qryUpdateToolHist", acNormal, acEdit
Beep
MsgBox "The Tool History table update has been completed.", vbOKOnly, "Tool History Update"
Else
MsgBox "The Tool History table update has not been completed.", vbOKOnly, "Tool History Update"
Exit Sub
End If
 
Try this...

Beep
If MsgBox("Do you want to update the Tool History table?", vbQuestion + vbYesNo, "Run Query") = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateToolHist", acNormal, acEdit
DoCmd.SetWarnings True
Beep
MsgBox "The Tool History table update has been completed.", vbInformation, "Tool History Update"
Else
Beep
MsgBox "The Tool History table update has not been completed", vbInformation, "Tool History Update Error"
End If

HTH
 
Thanks for all of your help!

I ended up making a form and using a message box. I made a seperate form for each query that is on the switchboard. When a button is pressed on the swithboard it runs the corresponding form.

The form gives two options: Run Query or Don't run query. When you click on the run button it runs the query and uses a message box to let the user know it ran successfully. When the user clicks on No, don't run query, it simply exists the form.

I know thats not the most efficient idea but its an idea to get by for now just to give the client the idea of what it is going to look like.

I might modify it in the next few days to try and make it more efficient but for testing purposes it works fine.

Thanks again for your help.
 

Users who are viewing this thread

Back
Top Bottom