Skip to main content

Notifications

Microsoft Dynamics GP forum
Unanswered

Using VBA to modify employee checks

Posted on by 75,730

I need to add some accrual information residing in the TATM1030 tro the EmployeeChecksOtherL. I was going to try to use VBA. I am getting error 424 on the initial connection. This form only has a body and I think it has something to do with section in which the code resides. What am I missing here. This connection technique works on other forms. This is the first time I have tried it with a report.

Private Sub Report_BeforeBody(SuppressBand As Boolean)

    If EmployeeID = "" Then Exit Sub
    'Get the hours accrued and hours available from the time and attendance table
    cmd.CommandText = "SELECT [HOURS_I],[HOURSAVAILABLE_I] FROM [UPR10208] T1 INNER JOIN [TATM1030] T2 ON T1.EMPLOYID=T2.EMPID_I='" & EmployeeID & "'"
    Set rst = cmd.Execute
    
    cPTOEarned = rst!HOURS_I
    cPTOUsed = rst!HOURSAVAILABLE_I

End Sub

Private Sub Report_End()
  'Release the objects we created
  Set rst = Nothing
  Set cmd = Nothing
  Set cn = Nothing

End Sub

Private Sub Report_Start()
    'Return an open ADO connection object using the credentials of the GP user logged into the current session
    Set cn = UserInfoGet.CreateADOConnection
    'Set the Default Database property to the company for the current session
    cn.DefaultDatabase = UserInfoGet.IntercompanyID
    
    'Setup to command object so it is ready for use
    cmd.ActiveConnection = cn
    cmd.CommandType = adCmdText

End Sub

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans