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.

What should we write about next?

Looking for support or consultancy with Microsoft Dynamics GP?

2 thoughts on “VBA Compile Error – Expected: expression

Leave a Reply to David Musgrave Cancel reply

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