J
JudyB
Can anyone help with the following code:
Private Sub Form Current()
Dim s As String
s = "SELECT JobTitleName,DepartmentName" & _
" FROM [Service Record Query] WHERE EmployeeID = " _
& Nz(Me.EmployeeID, 0) & " AND Status = Current;"
If Not Me.NewRecord Then
Me.Current_Job_Title_Name = CurrentDb.OpenRecordset(s).Fields(6)
Me.Current_Department_Name = CurrentDb.OpenRecordset(s).Fields(1)
Else
Me. Current_Job_Title_Name = Null
Me.Current_Department_Name = Null
End If
End Sub
I am trying to retrieve the Job Title Name and the Department Name from the
Service Record Query into two unbound text boxes (Current Job Title Name and
Current Department Name) located on the main form titled Employees. I am
getting a Run-time error 3061: Too few parameters: Expected 1. Do not
understand that at all. Do I first need to create a recordset based on the
query? If so, how? I tried putting the following code above the Private Sub
Form Current() code:
myRecordSet.Open “SELECT [Service Record].ServiceRecordID, [Service
Record].EmployeeID, [Service Record].DepartmentName, [Service
Record].JobTitleName, [Service Record].DateStart, [Service Record].DateEnd,
CalcWeeks([DateStart],[DateEnd]) AS WeeksService, [Service Record].Reason,
IIf(IsNull([DateEnd]),’Current’,’Null’) AS Status FROM [Service Record]â€
Another brick wall. Can anyone point me in the right direction? Am I even
close? Thanks in advance.
Private Sub Form Current()
Dim s As String
s = "SELECT JobTitleName,DepartmentName" & _
" FROM [Service Record Query] WHERE EmployeeID = " _
& Nz(Me.EmployeeID, 0) & " AND Status = Current;"
If Not Me.NewRecord Then
Me.Current_Job_Title_Name = CurrentDb.OpenRecordset(s).Fields(6)
Me.Current_Department_Name = CurrentDb.OpenRecordset(s).Fields(1)
Else
Me. Current_Job_Title_Name = Null
Me.Current_Department_Name = Null
End If
End Sub
I am trying to retrieve the Job Title Name and the Department Name from the
Service Record Query into two unbound text boxes (Current Job Title Name and
Current Department Name) located on the main form titled Employees. I am
getting a Run-time error 3061: Too few parameters: Expected 1. Do not
understand that at all. Do I first need to create a recordset based on the
query? If so, how? I tried putting the following code above the Private Sub
Form Current() code:
myRecordSet.Open “SELECT [Service Record].ServiceRecordID, [Service
Record].EmployeeID, [Service Record].DepartmentName, [Service
Record].JobTitleName, [Service Record].DateStart, [Service Record].DateEnd,
CalcWeeks([DateStart],[DateEnd]) AS WeeksService, [Service Record].Reason,
IIf(IsNull([DateEnd]),’Current’,’Null’) AS Status FROM [Service Record]â€
Another brick wall. Can anyone point me in the right direction? Am I even
close? Thanks in advance.