Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb yes no question

Status
Not open for further replies.

nevstic

Instructor
Jul 30, 2002
98
0
0
GB
Greetings all
would you help with the following please
I want to prduce a report on a vb yes no box, I have the first bit, but my report prints on both the yes answer and the no too !
could you fill me in please or is there an easier way than my attempt ?

Private Sub Command81_Click()
On Error GoTo Err_Command81_Click
Dim stDocName As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MsgBox "print receipt", vbYesNo
If vbYes Then
stDocName = "Receipt query"
DoCmd.OpenReport stDocName, acNormal
elseif vbno ?????

Exit_Command81_Click:
Exit Sub

Err_Command81_Click:
MsgBox Err.Description
Resume Exit_Command81_Click
End If

End Sub

many thanks
 
you need to assign your message box answer to an integer variable ie:

dim intAnswer as integer

intAnswer = msgbox "print receipt", vbYesNo

if intAnswer = vbyes then
...code here



jimlad
 
Try this...
Straight from the Help File!
Code:
Dim Msg, Style, Title, Response
Msg = "Would you like to print a receipt?"    ' Define message.
Style = vbYesNo + vbQuestion    ' Define buttons.
Title = "Print Receipt"    ' Define title.
' Display message.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then    ' User chose Yes.
    stDocName = "Receipt query"
    DoCmd.OpenReport stDocName, acNormal
End If


AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Hi and thanks fopr the quicko response fromyou both.
Jimlee
could you go a little deeper for me as this is new to me

The Int answer piece goes red ! and IO don't understand ?
do you have a more complete example ?

Many thanks
Nick
 
Sorry, forgot the brackets around the msgbox parameters, try this...(also moved your end if line)
Code:
Private Sub Command60_Click()
On Error GoTo Err_Command81_Click
    Dim intAnswer As Integer
    Dim stDocName As String
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
intAnswer = MsgBox("print receipt", vbYesNo)
If intAnswer = vbYes Then
    stDocName = "Receipt query"
    DoCmd.OpenReport stDocName, acNormal
  'elseif vbno ?????
End If
Exit_Command81_Click:
    Exit Sub

Err_Command81_Click:
    MsgBox Err.Description
    Resume Exit_Command81_Click


End Sub

jimlad
 
wonderful....many many thanks indeed

best rgds
Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top