Solved

Issue with my code in Dynamics GP 2010

Posted on 2011-02-18
7
695 Views
Last Modified: 2012-05-11
I have been working on a VBA code for Dynamics GP 2010 . the part that I have an issue right now is that I am updating a record that is not yet created.
well let me tell you a little more: on the RMA Entry Update Grid , I created a new field that display the UserDefine 3 ( my field is Cust Part#)  from the SVC05200 table for the current RMA.

so currently I am updating the table for this field when the field changes but that's not the best way, I thought using the saving button but everytime I click save the record gets clear.
How can I fix that?
 thanks
'*********
'update the UserDefined window for Customer Part
'*********
Private Sub StrCustPart_Changed()
    
    If IntRunCode = 1 Then
        'Retrieve an ADO Connection for the current user
        'Set the current Database company
        Set cn = UserInfoGet.CreateADOConnection
        cn.DefaultDatabase = UserInfoGet.IntercompanyID
        cmd.ActiveConnection = cn
               
        'push the cust part# in table SVC05200
        strsql = " Select count(*) from SVC05200 where RETDOCID = '" & RMAEntryUpdate.RMANumber & "' and LNSEQNBR = '" & CStr(CDbl(LineSequence)) & ".00000' "
        Set rst = cn.Execute(strsql)
        If rst.Fields(0).Value = 1 Then
            cmd.CommandText = " UPDATE SVC05200 set USRDEF03='" & StrCustPart & "' where RETDOCID = '" & RMAEntryUpdate.RMANumber & "' and LNSEQNBR = '" & CStr(CDbl(LineSequence)) & ".00000' "
            cmd.Execute
        Else
            MsgBox ("The line Item is not created yet. You need to Create the line item then retype the Customer Part#. If you don't retype it, the Customer Part will not be saved")
           ' StrCustPart.Value = ""
        End If
    End If

End Sub

Open in new window

0
Comment
Question by:taverny
  • 4
  • 3
7 Comments
 
LVL 10

Accepted Solution

by:
Abdulmalek_Hamsho earned 500 total points
ID: 34932818
You need to put your code after GP saves the line, which is the After_LineLostFocus event.
0
 

Author Comment

by:taverny
ID: 34933579
thanks I am gonna try that now
0
 

Author Comment

by:taverny
ID: 34933707
ok it works, maybe I should put all my custom fields in that . what do you think?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:Abdulmalek_Hamsho
ID: 34933722
If you mean "You're going to save all of the custom fields in the Line_AfterGotFocus", then yes, please go ahead. If this is not what you meant, then please elaborate.
0
 

Author Comment

by:taverny
ID: 34933739
ok. now I just thought of something.
if my user start creating a new RMA and a new line RMA and fill my custom field that is being updated only in the afterline lost focus. and then this user decide to delete the line before complation of the rma , is the deltee line will run before or after linelostfocus?
0
 
LVL 10

Expert Comment

by:Abdulmalek_Hamsho
ID: 34933782
DeleteLine (either using Edit -> Delete Line or by clicking the Delete Line button in the Grid header) doesn't make the line lose focus, so it runs before Line_AfterLostFocus unless if the user focused on a field outside the Grid.
0
 

Author Comment

by:taverny
ID: 34933788
ok it works for me.
I am gonna open another question related to that right now.
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now