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

training access vba london - word vba

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

training access vba london - Word vba

ResolvedVersion 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:

Stop Display Alerts In Excel

When creating or deleting a Worksheet in Excel you don't want Excel to inform you "A file already exists....." Or "Do you want to save this file...".

To stop these alerts happening use the following line of code:

Application.DisplayAlerts = False

After the Create or Delete routine use:

Application.DisplayAlerts = True

View all VBA hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.