Enquiry about coding explantion

s1police

Registered User.
Local time
Tomorrow, 04:26
Joined
Aug 1, 2007
Messages
50
Dear All,

I have write some VBA coding for a field. It is about after select the Employee Name, then VBA will run and get the outcharge rate for that employee and fill-in the field automatically. The code is as follow.

The file is saved in a network drive, and the coding run normally in my local computer. However, when I did the testing from my colleague's computers, there is error prompted out said the blue code is missing library. After I changed to "RecordSet.Open MySQL", it can be run from their computer.

Anyone can explain to me that the different between this 2 coding?
1. RecordSet.Open MySQL, , adOpenStatic
2. RecordSet.Open MySQL

I do know why after I delete the code behind, it can be run. Please kindly teach me on this. Thanks!!!!:confused:


Private Sub man_days_employee_AfterUpdate()
On Error GoTo man_days_employee_AfterUpdate_Err

Dim Outcharge As Currency
Dim EmployeeID As String
EmployeeID = Me.man_days_employee.Value

Dim cnn As ADODB.Connection
Dim RecordSet As New ADODB.RecordSet

Set cnn = CurrentProject.Connection
RecordSet.ActiveConnection = cnn

Dim MySQL As String
MySQL = "SELECT DISTINCT positions.outcharge_rate " & _
"FROM positions INNER JOIN employees " & _
"ON (positions.position_id = employees.position_id) " & _
"AND (positions.position_id = employees.position_id) " & _
"WHERE employees.employee_id = " & EmployeeID

RecordSet.Open MySQL, , adOpenStatic

Outcharge = RecordSet!outcharge_rate
Me.outcharge_rate.Value = Outcharge


Set cnn = Nothing
Set RecordSet = Nothing


man_days_employee_AfterUpdate_Exit:
Exit Sub

man_days_employee_AfterUpdate_Err:
MsgBox Err.description
Resume man_days_employee_AfterUpdate_Exit
End Sub
 

Users who are viewing this thread

Back
Top Bottom