Hi,
I am just starting out in the world of VBA and I am creating a DB which is borrowing code from another DB (created from my programmer co-worker). Even though the functionality in each DB is the same, mine keeps coming up with a compile error. My co-worker is on vacation for 2 wks...I'd appreciate any help. It errors out at the Set prm line. Thanks!
Code:
Private Sub EmployeeNumber_AfterUpdate()
Dim EmpNo As Integer
EmpNo = Me.EmployeeNumber.Value
Set prm = New ADODB.Parameter
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
'Setup the command object
With cmd
.CommandText = "qryEmpInfo"
.CommandType = adCmdUnknown
'create the parameter
Set prm = .CreateParameter("EmpNo", adVarChar, adParamInput, 5)
.Parameters.Append prm
'set the parameter's value
.Parameters("EmpNo") = EmpNo
'Associate the command object with a connection
.ActiveConnection = CurrectProject.Connection
'request the recordset
Set rs = .Execute
I am just starting out in the world of VBA and I am creating a DB which is borrowing code from another DB (created from my programmer co-worker). Even though the functionality in each DB is the same, mine keeps coming up with a compile error. My co-worker is on vacation for 2 wks...I'd appreciate any help. It errors out at the Set prm line. Thanks!
Code:
Private Sub EmployeeNumber_AfterUpdate()
Dim EmpNo As Integer
EmpNo = Me.EmployeeNumber.Value
Set prm = New ADODB.Parameter
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
'Setup the command object
With cmd
.CommandText = "qryEmpInfo"
.CommandType = adCmdUnknown
'create the parameter
Set prm = .CreateParameter("EmpNo", adVarChar, adParamInput, 5)
.Parameters.Append prm
'set the parameter's value
.Parameters("EmpNo") = EmpNo
'Associate the command object with a connection
.ActiveConnection = CurrectProject.Connection
'request the recordset
Set rs = .Execute