Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Using VBA to modify employee checks

(2) ShareShare
ReportReport
Posted on by 75,788 Moderator

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

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans