Cancel Button on message box

dcaraher

New member
Local time
Today, 19:37
Joined
Dec 4, 2009
Messages
2
I have a very simple macro added to a control button which opens a parameter query.

The message box that opens asks the user to input some detail, all works well if the user inputs the detail and then clicks"OK". However if they dont enter any detail and press cancel I get the action failed message box with the error number 2950.

If I then click stop all macros I can exit the error message.

is there a way I can amend the macr so that if the user clicks cancel the message box closes without running the macro?
 
Handle this instead.
The message box that opens asks the user to input some detail, all works well if the user inputs the detail and then clicks"OK". However if they dont enter any detail and press cancel I get the action failed message box with the error number 2950.

Instead of the query prompt:

1. create a pop-up form with a textbox for getting the user's input
2. before opening the main form, test to see if the user has entered a value or left it blank:
Code:
If Len(Me.txtbox & "") = Then
    Msgbox "Please enter some detail"
Else
    DoCmd.OpenForm "FormName"
    Me.Visible = False
End If
3. Link that textbox to the record source of the main form using:
Code:
[Forms]![[COLOR=Red]NameOfForm[/COLOR]]![[COLOR=Red]NameOfTextbox[/COLOR]]
Amend the bits in red. This will replace the prompt in the query.
 
Thanks for the reply.

I'm not sure I have explained my problem clearly. The message box appears as a reult of the control button being clicked and the macro running the OpenQuery action. The query is a parameter query so the message box is asking for the parameters.

If the user clicks cancel rather than OK on the message box I get the error described.

I'm not sure how to get your solution to fit my problem, however that could just be me being very dim:confused:
 
You cannot trap the Cancel button of the pop-up input dialog box in a parameterized query which is why you need a form to get the value instead.

What step do you not understand?
 

Users who are viewing this thread

Back
Top Bottom