B
bymarce
I'm trying to make a list from a recordset with the following code. When I
run it, I get the error "No Current Record" but the query shows several
records. Thanks.
Marcie
'Make mlo list for subject.
Dim DEMLOqd As QueryDef
Set DEMLOqd = CurrentDb.QueryDefs("qryDEMLO")
Dim qryDEMLOsql As String
qryDEMLOsql = "SELECT DISTINCT DataEntry.[MLO] "
qryDEMLOsql = qryDEMLOsql & "FROM DataEntry;"
DEMLOqd.sql = qryDEMLOsql
DEMLOqd.Close
DoCmd.OpenQuery "qrydemlo"
Dim DEMLOdb As Database
Dim DEMLOrs As DAO.Recordset
Dim strMLO As String
Set DEMLOdb = CurrentDb()
Set DEMLOrs = DEMLOdb.OpenRecordset(qryDEMLOsql, dbOpenSnapshot)
If DEMLOrs.BOF = True And DEMLOrs.EOF = True Then
MsgBox "There are no MLO #s listed."
GoTo ErrExit
End If
Do Until DEMLOrs.EOF
strMLO = strMLO & DErs.Fields("MLO") & ", " (this line is
highlighted.)
DEMLOrs.MoveNext
Loop
Debug.Print strMLO
run it, I get the error "No Current Record" but the query shows several
records. Thanks.
Marcie
'Make mlo list for subject.
Dim DEMLOqd As QueryDef
Set DEMLOqd = CurrentDb.QueryDefs("qryDEMLO")
Dim qryDEMLOsql As String
qryDEMLOsql = "SELECT DISTINCT DataEntry.[MLO] "
qryDEMLOsql = qryDEMLOsql & "FROM DataEntry;"
DEMLOqd.sql = qryDEMLOsql
DEMLOqd.Close
DoCmd.OpenQuery "qrydemlo"
Dim DEMLOdb As Database
Dim DEMLOrs As DAO.Recordset
Dim strMLO As String
Set DEMLOdb = CurrentDb()
Set DEMLOrs = DEMLOdb.OpenRecordset(qryDEMLOsql, dbOpenSnapshot)
If DEMLOrs.BOF = True And DEMLOrs.EOF = True Then
MsgBox "There are no MLO #s listed."
GoTo ErrExit
End If
Do Until DEMLOrs.EOF
strMLO = strMLO & DErs.Fields("MLO") & ", " (this line is
highlighted.)
DEMLOrs.MoveNext
Loop
Debug.Print strMLO