Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Using VBA to modify employee checks

(2) ShareShare
ReportReport
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

Categories:

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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans