Solved

Issue with my code in Dynamics GP 2010

Posted on 2011-02-18
7
697 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CRM 2016 onl cloud - Web Development 2 124
CRM 2011 User, email and phone number for SSRS 4 65
Microsoft Dynamics 365 2 221
Dynamics crm 2011 8 85
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…
Automatically creating a Trello card using data from a Microsoft Dynamics CRM record turned out to be an easy project that yielded great results.  Here's how I did this for an internal team at General Code.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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