sending access table object to public sub or function as argument

I am wanting to send one of the tables in my access database as an argument to a Public Function I have created that needs to open the table as a recordset.  I want to be able to send different tables to the function and have it perform the code using each table as the same variable.  I can't seem to figure out how I need to pass it to the function.  I have pasted the code that I am calling below.  I am wanting to call it like this FillQAblanks(tbl_GENQA) but this dosen't seem to work.


Public Function FillQAblanks()
Dim rsttblGENQA As ADODB.Recordset
Set rsttblGENQA = New ADODB.Recordset
Dim rstqryEmpdataGEN As ADODB.Recordset
Set rstqryEmpdataGEN = New ADODB.Recordset
Dim qryEmpdataGEN As String
Dim month1, month2, month3, month4, month5, month6 As Date
Dim myscore, mycount, myloops As Integer
 
rsttblGENQA.Open "tbl_GENQA", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rstqryEmpdataGEN.Open "qry_EmpdataGEN", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
 
rsttblGENQA.MoveFirst
Do While rsttblGENQA.EOF = False
    myaverage = 0
    mymonth = #8/15/2008#
    Do
        Select Case mymonth
            Case #8/15/2008#
                mymonth = #9/15/2008#
            Case #9/15/2008#
                mymonth = #10/15/2008#
            Case #10/15/2008#
                mymonth = #11/15/2008#
            Case #11/15/2008#
                mymonth = #12/15/2008#
            Case #12/15/2008#
                mymonth = #1/15/2009#
            Case #1/15/2009#
                mymonth = #2/15/2009#
        End Select
        If Date >= mymonth Then
            rstqryEmpdataGEN.MoveFirst
            rstqryEmpdataGEN.Find "[Full Name] = '" & rsttblGENQA.Fields(0).Value & "'"
            If rstqryEmpdataGEN.Fields(4).Value <= mymonth - 180 Then
                If IsNull(rsttblGENQA.Fields(1).Value) Then
                    If myaverage = 0 Then
                        myscore = 0
                        mycount = 0
                        myloops = 1
                        Do
                            If Not IsNull(rsttblGENQA.Fields(myloops).Value) And rsttblGENQA.Fields(myloops).Value <> 0 Then
                                myscore = myscore + rsttblGENQA.Fields(myloops).Value
                                mycount = mycount + 1
                            End If
                            myloops = myloops + 2
                        Loop Until myloops = 13
                        If mycount <> 0 Then
                            myaverage = myscore / mycount
                            rsttblGENQA.Fields(1).Value = myaverage
                            rsttblGENQA.Update
                        Else
                            myaverage = Null
                        End If
                    Else
                        rsttblGENQA.Fields(1).Value = myaverage
                        rsttblGENQA.Update
                    End If
                End If
            Else
                rsttblGENQA.Fields(1).Value = 0
                rsttblGENQA.Update
            End If
        End If
    Loop Until mymonth = #2/15/2009#
 
    rsttblGENQA.MoveNext
Loop
rstqryEmpdataGEN.Close
rsttblGENQA.Close
End Function

Open in new window

redrpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
1. Public Function FillQAblanks(tname as string)


10. rsttblGENQA.Open tname CurrentProject.Connection, adOpenKeyset, adLockOptimistic


You call it like..
x = FillQABlanks("tbl_GENQA")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
redrpAuthor Commented:
Worked perfectly!  Thank you for keeping it simple and easy!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.