[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Issue with my code in Dynamics GP 2010

Posted on 2011-02-18
7
Medium Priority
?
703 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 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part III
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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