Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

Adding Customer Inactive checkbox to National Accounts form.

Posted on by

I'm struggling with a way to show the RM00101.INACTIVE field for Child Customers on the National Accounts Maintenance form. I don't want to restrict the Child Customers that show. I just need the checkbox to show if the Child account is Active ( unchecked ) or Inactive ( checked ). 

I added a checkbox field to the ChildScroll scrolling window but I can't come up with a vba script to populate the checkbox based on the Child Accounts returned.

Any help or sample code would be appreciated.

Thanks

DavidF.

*This post is locked for comments

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    My code didn't work for your environment because we have different custom local fields, I am glad your code is working after looking to my snippet. :-)

  • Verified answer
    davidf. Profile Picture
    davidf. on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Thanks Almas,

    I marked yours as the answer even though your code did not work in my environment. You did help me clean up the jumbled mess of code I was trying to make work.

    I started clean and came up with a working modification.

    So to summarize:

    1. I added the RM_NationalAccounts_Maintenance window to Modifier.
    2. I created a Checkbox field named "CustInactive"  and added it to the scrolling Window, making room between the CustomerName and CurrentBalance fields.
    3. I added the RM_NationalAccounts_Maintenance window to VBA
    4. Added the CustomerNumber and CustInactive fields to VBA.
    5. Then added this vba code.
      1. ***  Start of VBA Code ***

        Option Explicit

        'Open the ADO connection

        Dim cn As New ADODB.Connection
        Dim rst As New ADODB.Recordset
        Dim cmd As New ADODB.Command

        Private Sub Grid_AfterLineLostFocus()

        'This code clears all variables used and closes the connections.

        If rst.State = adStateOpen Then rst.Close
        If cn.State = adStateOpen Then cn.Close

        End Sub


        Private Sub Grid_BeforeLinePopulate(RejectLine As Boolean)
        'Opens the connection to the Customer Master and retrieves the Inactive field

        'This code looks to see if there is already an open connection and if
        'so a command object for read-only recordsets will be established
        If rst.State = adStateOpen And cn.State = adStateOpen Then
        cmd.ActiveConnection = cn

        'This retrieves the Inactive field from Customer Master

        cmd.CommandType = adCmdText
        cmd.CommandText = "SELECT INACTIVE FROM RM00101 WHERE CUSTNMBR='" & CustomerNumber & "' "

        'This updates the CustInactive field which is a Checkbox Field Added via
        'Modifier to the NationalAccountsMaintDetail grid

        Set rst = cmd.Execute
        CustInactive = rst!Inactive

        Else
        'If a connection is not open, then the following will establish a link
        'to the data, create the recordset and select the data.
        Set cn = UserInfoGet.CreateADOConnection
        cmd.ActiveConnection = cn
        cmd.CommandType = adCmdText

        'Updates the CustInactive field

        cmd.CommandText = "SELECT INACTIVE FROM RM00101 WHERE CUSTNMBR='" & CustomerNumber & "' "
        Set rst = cmd.Execute
        CustInactive = rst!Inactive
        End If
        End Sub

        *** End of VBA Code ***

    Thanks so much for your help. This is now working exactly the way I want it to.

    David

  • Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Come on .. !

    It is absolutely an honor Ms. Almas Mahfooz  ;)

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Just trying to be like great Saadi. :)

  • Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Almas Mahfooz

    Nice article ... as usual, always such a hard working person ;)

  • Verified answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    here http://evspakistan.wordpress.com/2014/08/05/adding-customer-inactive-checkbox-to-national-accounts-form/  find code snippet for your requirement. Don't need to mention you have to mark modified form to do the stuff.

    almas

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Davis,

    That's what I tell you on first place, that if going for VBA then you should have expertise on it.

    Dexterity is the best option if you know it.

    btw you didn't mention any error you are getting, while running your code.

     

     

  • soma Profile Picture
    soma 24,406 on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    I am not sure whether you can achieve your requirement by using VBA. But, you can achieve the same by using Dexterity.

    Hope this helps!!!

  • davidf. Profile Picture
    davidf. on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    Tried it, still not getting any results. I just want the grid to show whether  the Child account is Active (0) or Inactive (1).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Adding Customer Inactive checkbox to National Accounts form.

    did you try writing this validation in grid_AfterLinePopulate, which is equivalent to line fill event in dexterity.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans