training access vba london - word vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » training access vba london - Word vba

training access vba london - Word vba

resolvedResolved · Low Priority · Version Standard

Jane has attended:
Word VBA course
Word VBA course

Word vba

am preparing a template and am asking a question which i need a message box to appear. i have inserted the following code

Private Sub EUVAT_Click()
If BillAmounts.EUVAT = Yes Then
Sub NewMessage()
MsgBox("Is the Client VAT number shown above correctly?", vbYesNo) = vbYes
End If
End Sub

when i click yes in the template BillAmounts gets highlighted and error Expected End Sub.

I would be grateful for some help, I havent done any vba since training in June !


RE: word vba

Hi Jane

The error message is due to the fact you did a Sub Newmessage in the middle of the if statement. Try the following code istead:

Private Sub EUVAT_Click()

Dim Reply As Byte

If BillAmounts.EUVAT = Yes Then

Reply = MsgBox("Is the Client VAT number shown above correctly?", vbYesNo)

If Reply = vbYes Then

'Code for Yes reply

Else

'Code for No reply

End If

End If

End Sub


Hope this helps

Carlos

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Display Text In a Msgbox On Multiple Lines

When displaying text in a MsgBox you may need to show it over multiple lines. To do this use:

vbCrLf

As in:

MsgBox "The System has detected an error." & vbCrLf & "Contact your System Administrator"

The first sentence in quotes will appear above the second in the MsgBox.

View all VBA hints and tips


Server loaded in 0.07 secs.