Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Query Result to a Table

Status
Not open for further replies.

samn265

Technical User
Feb 12, 2002
35
US
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
 
It might just be me, or it might just be Tuesday, but I'm totally unclear here on what you are trying to do. First you declare a recordset based on a query, and you step through it record by record. But each time you move, you run another query. What does this other query do? Where does "activeEmployeeName" come from?

What EXACTLY are you trying to do?

Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
JimAtTheFAA,
Sorry for the confusion. Please ignore the line where it says: DoCmd.OpenQuery "qryAppendEmployeesQuery". I was trying to do testing with that query.

Every time I move to the next record, I am basically getting the name of the next employee in which I would to like to perform a calculation to see whether or not he/she is eligible for reward days.

I am able to successfully move from one employee to another but I can't seem to insert the name of that employee in a table, which is used along another query to get info only for that employee out of many others.

"activeEmployeeName" is the function name that carries the name of that employee.

I hope this clears up the confusion.
 
It helps a little, but I don't see why you're needing a programmed function to do this - it should be doable in a standard select query that will give you the names of all the employees who meet your test with about .05 of the fuss.

What makes an employee "eligible"? Can that be constructed as a calculation in a query? Then make the criteria for that calculation "Eligible" or whatever and run the query.

Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top