Solved

Issue with my code in Dynamics GP 2010

Posted on 2011-02-18
7
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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