Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to Get VBA to Handle "This Customer ID does not exist."

(0) ShareShare
ReportReport
Posted on by

Hello:

In GP 2013 R2 (12.00.1920), I have VBA code for a customer-based window.

My code works perfectly, as long as the end user types in an existing customer ID into the "Customer ID" field.  But, if the user accidentally types in a customer ID that does not exist, GP brings up the dialogue box "This Customer ID does not exist."

When the user hits "OK", afterward, VBA brings up that "Debug" window saying among other things that the integrity of the application could be violated.  (This is the "Run-Time Error '1007'" window that mentions "Unsafe Operation".)

Although the end user can click "End" on this window and move on, it's still an issue that needs to be eliminated. 

Specifically, when I troubleshoot this VBA error by clicking the "Debug" button instead of the "End" button, the yellow breakpoint in the Visual Basic Editor appears within my first of five "AfterUserChanged" events.

What I'm trying to say is that the end user has changed the Customer ID field, of course, by entering a bad Customer ID and tabbing out of the field.  My VBA code does not know how to handle this.

I tried to fix this, by adding the code below to place the focus of GP back into the Customer ID field and so that the end user can enter a correct customer ID for my code to run. 

But, the same "Run-Time Error '1007'" window appears.

How do I eliminate this issue?

Thanks!

John

Private Sub Window_AfterModalDialog(ByVal DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
Select Case PromptString
    Case "This customer ID does not exist."
    If Answer = dcOK Then
    CustomerID.Focus
    End If
    Case Else
    End Select
End Sub

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to Get VBA to Handle "This Customer ID does not exist."

    Update:  I resolved this by using the BeforeGotFocus event for the Customer ID field, instead of the AfterUserChanged event.  :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Almas Mahfooz Profile Picture

Almas Mahfooz 3 User Group Leader

Featured topics

Product updates

Dynamics 365 release plans