openrecordset not working

Rosana

New member
Local time
Today, 07:53
Joined
Aug 25, 2017
Messages
9
HI,
I am trying to use openrecordset to access query fields but nothing happens. What am I doing wrong?
Code:
Public Function test() As String
    Dim db As DAO.Database
    Dim rst As Recordset
    'Dim qryfld As DAO.QueryDef
    'Dim fld As Field
 
    Set db = CurrentDb()
    Set rst = db.OpenRecordset("Copy Of Mail Merge", dbOpenDynaset)
 Dim addresses As String
    addresses = rst.Fields(0).Value
          addresses = rst!address
        
    test = addresses
End Function

Thank you for any help.
 
How do you use the function? What do you expect should happen that isn't?
Mark
 
I am calling the function in immediate window for testing purposes. I have also placed breakpoint in the code and when it hits this below line, it goes back to the beginning. No error nothing.

Set rst = db.OpenRecordset("Copy Of Mail Merge", dbOpenDynaset) 'hits this line and goes back to beginning

My intention is to open my query as a record set and access one of it's field values.

Thank you.
 
Hi. How are you calling the function specifically? What exactly do you type in the immediate pane in order to run the function?

I don't understand this observation...
'hits this line and goes back to beginning
So the debugger breaks on the indicated line, and you hit F8 function key to 'step into' and what happens? What goes back to the beginning?

Mark
 

Users who are viewing this thread

Back
Top Bottom