Solved

Issue with my code in Dynamics GP 2010

Posted on 2011-02-18
7
698 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Problem to path 13 79
Dynamic CRM 2016 Cloud 3 99
CRM 2011 Add a MsgBox  to replace an Error Message 4 143
Duplicate Detection - CRM 2011 2 51
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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