Below is a function to step through a query, one record at a time until the end of the file. I am having a trouble inserting the value of each record “ActiveEmployeeName” to a table. I do not want to append to the table. I just want to have one record in that table which is the value that is passed from the function. I tried to use Make_Table query but it did not work. Any idea of how to do this code?
Function ActiveEmployeeName() As String
Dim rstError As DAO.Recordset
Set rstError = CurrentDb.OpenRecordset("qrySelectCountofActiveEmployees"
Do Until rstError.EOF
'MsgBox "Last Name is: " & rstError!LastName
DoCmd.OpenQuery "qryAppendEmployeesQuery"
ActiveEmployeeName = rstError!LastName
MsgBox "Last Name is: " & ActiveEmployeeName
rstError.MoveNext
Loop
rstError.Close
Set rstError = Nothing
End Function
I appreciate your help. Thanks,
Sam
Function ActiveEmployeeName() As String
Dim rstError As DAO.Recordset
Set rstError = CurrentDb.OpenRecordset("qrySelectCountofActiveEmployees"
Do Until rstError.EOF
'MsgBox "Last Name is: " & rstError!LastName
DoCmd.OpenQuery "qryAppendEmployeesQuery"
ActiveEmployeeName = rstError!LastName
MsgBox "Last Name is: " & ActiveEmployeeName
rstError.MoveNext
Loop
rstError.Close
Set rstError = Nothing
End Function
I appreciate your help. Thanks,
Sam