VBA Compile Error – Expected: expression

Microsoft Dynamics GPI realise that the use of VBA in modifications and customisations is something that needs to be carefully considered with Microsoft Dynamics GP 2013 including a Silverlight based Web Client which cannot use VBA. I had a requirement from a client for a modification to the Debtor Enquiry (Customer Inquiry to the Americans reading) to include the sum of the displayed transactions on the window and as this was a small client with GP installed locally on each PC there is no requirement for the web client, I felt able to perform this change using Modifier using some VBA.

I added the required fields to the VBA project but encountered an error message when writing the VBA code to concatenate the fields into the SQL statement I was going to use to get the data;

Microsoft Visual Basic: Compile error: Expected: expressionMicrosoft Visual Basic: Compile error: Expected: expression

It took me a few minutes to realise that the cause of the error is that To is a restricted keyword in VBA. Once I had realised this, I was able to quickly work around the error by updating the code to refer to the field To with more accuracy;

Microsoft Visual Basic

The red ringed text shows how I got VBA to accept the variable. The Me refers to the Debtor Enquiry window and specifies that To is not a keyword but a child object of the window.

Can ISC Software Solutions help?

ISC Software Solutions are UK and Ireland based experts on Microsoft Dynamics GP. If you’d like to speak to someone about support, consultancy, upgrades, implementation, development, GP Elementz add-ons or portals, or anything else Dynamics GP related, you can use the form below.





Your Name (required):
Your Email (required):
Subject:
Enquiry message:

What should we write about next?





Your Name (required) –
Your Email (required) –

2 thoughts on “VBA Compile Error – Expected: expression

  1. Pingback: Comment

Leave a Reply

Your email address will not be published. Required fields are marked *