Passing RecordSet as a parameter (1 Viewer)

richard_lowenthal

New member
Local time
Yesterday, 20:30
Joined
Sep 19, 2014
Messages
1
Hi, I'm trying to the following sub to automate the creation of RecordSets but I'm confuse how to get it done properly.

Public Sub OpenRecordSet(SQLString As String, NameRecordset As Object)
Set NameRecordset = New ADODB.Recordset
NameRecordset.Open SQLString, adOpenStatic, adLockOptimistic

I want to pass the name of the recordset as a parameter but I don't know how to set it.

Thanks in advance.
 

DonkeyKong

Registered User.
Local time
Yesterday, 18:30
Joined
Jan 24, 2013
Messages
61
The stuff you want is in bold... the rest is just from stuff i used to test it

Code:
Function bQueryVerifyControlValue(strSQL As String, strFieldName As String, ctrl As Control) As Boolean

 
Dim rst As New ADODB.Recordset
    
On Error GoTo ERROR_EXIT
 
    bQueryVerifyControlValue = False
    rst.Open strSQL, cnn, adOpenStatic
    rst.MoveFirst
    Do While Not rst.EOF
        If rst(strFieldName) = ctrl.Value Then
            bQueryVerifyControlValue = True
            Exit Do
        End If
        rst.MoveNext
    Loop
    
 [B]arecords rst, strFieldName
[/B]    
ERROR_EXIT:
    
End Function
 
[B]Sub arecords(rst As ADODB.Recordset, strFieldName As String)
Dim str As String[/B]
[B]    rst.MoveFirst
    str = rst(strFieldName)
    MsgBox str[/B]
[B]End Sub[/B]
[B]
[/B]
 

Users who are viewing this thread

Top Bottom