If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Cannot Get the Yes Button to open Report
New to code, I can get the message box to open, but cannot get the report to
open when I click the Yes Buttom. Can anyone see what I have done wrong with the code. Thank You Jesse Private Sub Form_AfterInsert() Dim Msg, Style, Title, MyString Msg = "Would You Like To Print Label" ' Define message. Style = 4 + 16 + 0 ' Define buttons. Title = "ESS Label" ' Define title. Dim stDocName As String If Me![Text6] = 3 - 1 Then Response = MsgBox(Msg, Style, Title) ElseIf Response = vbYes Then ' User chose Yes. MyString = "Yes" DoCmd.OpenReport "person" ' Perform some action. Else ' User chose No. MyString = "No" ' Perform some action. End If End Sub -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200901/1 |
#2
|
|||
|
|||
Cannot Get the Yes Button to open Report
Temporarily add another MsgBox to indicate if the report opened or not. This
will help you identify whether the problem is with your code or with something else (such as the report's query is incorrect, or its Open or NoData event is cancelled, or the printer is not working, or ...) Private Sub Form_AfterInsert() Dim strMsg As String strMsg = "Would You Like To Print Label" If MsgBox(strMsg, vbYesNo+vbQuestion, "ESS Label") = vbYes Then DoCmd.Report "person" MsgBox "Report opened" End If End Sub Other suggestions: - Make sure you have Option Explicit at the top of this (and all other) modules. - Make sure your code compiles (Compile on Debug menu in code window.) - Don't declare all variables on one line. Instead declare each one with its type (e.g. "As String" above.) -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "jesseu via AccessMonster.com" u39476@uwe wrote in message news:908d72cb82bd4@uwe... New to code, I can get the message box to open, but cannot get the report to open when I click the Yes Buttom. Can anyone see what I have done wrong with the code. Thank You Jesse Private Sub Form_AfterInsert() Dim Msg, Style, Title, MyString Msg = "Would You Like To Print Label" ' Define message. Style = 4 + 16 + 0 ' Define buttons. Title = "ESS Label" ' Define title. Dim stDocName As String If Me![Text6] = 3 - 1 Then Response = MsgBox(Msg, Style, Title) ElseIf Response = vbYes Then ' User chose Yes. MyString = "Yes" DoCmd.OpenReport "person" ' Perform some action. Else ' User chose No. MyString = "No" ' Perform some action. End If End Sub |
Thread Tools | |
Display Modes | |
|
|