web
You’re offline. This is a read only version of the page.
close
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,848 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:
I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans