Access Access 97 If Then Else button On Click problem

Joined
Aug 31, 2009
Messages
1
Reaction score
0
I have created a form with a button on click event procedure. When the button "Publish All" is clicked on the form, On click it should display a message box asking if all reports should be exported to static html files after passing through a template for format; that is, "Do you wish to publish the entire web site?" For the message box there should be two buttons - "Yes" and "No".

If the "Yes" button is clicked, the original On Click event should proceed by executing a series of DoCmd.OutputTo acOutputReport lines then end the sub routine.

If the "No" button is clicked it should end the sub routine immediately.

However, I'm very new to this and am having a problem.

When the "Publish All" button is clicked to begin the event procedure it opens the message box with the message and the yes/no buttons. But then it's not following the If Then Else block. No matter which button (Yes/No) is clicked, it begins executing all of the DoCmd lines.

That is:
If vbYes it begins to run the DoCmd.OutputTo lines of code which is what it should do.
HOWEVER, if vbNo (i.e., the "No" button is clicked) it acts as if the "Yes" button has been clicked and doesn't immediately end the sub routine.

Here is a snippet of the event procedure...

Private Sub PublishAll_Click()
Dim Msg, Style, Title, Response, MyString
Msg = "Do you wish to publish the entire web site except the blogs and playlist?"
Style = vbYesNo (Note: adding additional definitions such as vbCritical + vbDefaultButton2 e.g. has no effect)
Title = "Publish web site"
Response = MsgBox(Msg, Style, Title)
If vbYes Then
MyString = "Yes"
(Beginning on thise line follows several DoCmd.OutputTo acOutputReport lines to be executed)
Else
MyString = "No"
End Sub (I'm unsure what this line should state, but several attempts at other statements have also had no effect.)

End If
End Sub
 
Back
Top