Re: ADODB Recordset and Connection



Thank you - the error is gone and it sort of works :)
I think I'm kind of getting the hang of it
--
Piper


"roger" wrote:

"Piper" <Piper@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FA68CB1C-1B5F-4F00-A891-A31F4C303250@xxxxxxxxxxxxxxxx
Ok I'm getting smarter, so I think, but it still dosent work!

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

That should be "AND" not "&"...

If rcdSet.EOF = True AND rcdSet.BOF = True _
Then


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

Set rcdSet = New ADODB.Recordset

I don't think you need the line above. You already have...
"Dim rcdSet As New ADODB.Recordset"
in the first procedure.


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

Set setRcdSet = rcdSet

End Function

Function setCnxn() As ADODB.Connection

On Error GoTo ErrorHandler

Get rid of the line above, until the code is working


Dim cnxnStr As String

Here you need...

Dim Cnxn As ADODB.Connection


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

That should be...
Set Cnxn = New ADODB.Connection

Cnxn.CursorLocation = adUseServer
Cnxn.Open cnxnStr

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


--
roger



.



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
    ... I’ve updated my setRcdSet and setCnxn to Function's insted of Sub's. ... Dim noPh As String, qry As String ... Dim rcdSet As New ADODB.Recordset ...
    (microsoft.public.data.ado)
  • Re: Import Access records to excel (parameter is a called funct) v.20
    ... Function PricesForSpecifiedDate(DBName As String, ... Dim Cmd As ADODB.Command ... Dim Param As ADODB.Parameter ... Dim Cnxn As ADODB.Connection ...
    (microsoft.public.excel.programming)
  • Re: Degradation of performance : upgrading from Excel 2000 to Excel 20
    ... well we are nuclear powered here Roger with Winfrith just down the road ... I tried switching off multithreaded calculation mode in ... Dim i As Long ... this code works both on Excel 2000 and on Excel 2003 but on the same ...
    (microsoft.public.excel.programming)
  • Re: "If ......Exists.... Then Run SQL code"
    ... Roger, here is the code to delete all records from a table, and reset the ... Dim cat As New ADOX.Catalog ... Dim strSql As String ... > programming, I have ended up in this format. ...
    (microsoft.public.access.modulesdaovba)