RE: ADODB Recordset and Connection



Ok I'm getting smarter, so I think, but it still dosent work!

I’ve updated my setRcdSet and setCnxn to Function's insted of Sub's. So I
can return the Connection and ResultSet, theoretically anyway - it still
physically doesn’t work. I now have this (abbreviated version):

Sub createListBX()

Dim noPh As String, qry As String
Dim cpFrm As Form
Dim rcdSet As New ADODB.Recordset

noPh = getNme(Forms!Emp_Form!Emp_ID) + " has no Dept Issued Cell Phones."
qry = cpByIDQry(Forms!Emp_Form!Emp_ID)

Set rcdSet = setRcdSet(rcdSet, qry)

If rcdSet.EOF = True & rcdSet.BOF = True _
Then
'CP_ListBX.Height =
CP_ListBX.ColumnCount = 1
CP_ListBX.ColumnWidths = "3.75 in"
CP_ListBX.AddItem (noPh)
Else
fillListBX CP_ListBX, rcdSet
End If

cleanUpRcdSet rcdSet

End Sub
_____________________________________________________
Function setRcdSet(rcdSet As ADODB.Recordset, query As String) _
As ADODB.Recordset

Set rcdSet = New ADODB.Recordset

rcdSet.Open query, setCnxn, adOpenDynamic, adLockOptimistic, adCmdText

Set setRcdSet = rcdSet

End Function
_______________________________________________________________
Function setCnxn() As ADODB.Connection

On Error GoTo ErrorHandler

Dim cnxnStr As String

cnxnStr = "Driver={Microsoft Access Driver " _
& "(*.mdb)};Dbq=U:\PersonnelDB\CC_Personnel.mdb;"
Cnxn = New ADODB.Connection
Cnxn.CursorLocation = adUseServer
Cnxn.Open cnxnStr

Set setCnxn = Cnxn
****************
End Function
__________________________________________________________

Now I get to the part with the *'s and when I added a MsgBox with
setCnxn.State it showed a 1, so I know at that point the connection is open.
It just dosen't return an open Connection, the Connection it returns shows
Closed.

Any suggestions???
Thanks
--
Piper
.



Relevant Pages

  • Re: ADODB Recordset and Connection
    ... Dim noPh As String, qry As String ... Dim rcdSet As New ADODB.Recordset ... Dim Cnxn As ADODB.Connection ...
    (microsoft.public.data.ado)
  • Re: ADODB Recordset and Connection
    ... "roger" wrote: ... Dim noPh As String, qry As String ... Dim rcdSet As New ADODB.Recordset ... Dim Cnxn As ADODB.Connection ...
    (microsoft.public.data.ado)