MS Access EOF and BOF property problems please help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

MS Access EOF and BOF property problems please help

madbrainmadbrain Posts: 1Member
I don't seem to be able to get MS Access to return the BOF and EOF property of the RecordSet rsDB

I whant to check of the Returned recordset is Empty with EOF and BOF is True but somehow it keeps giving the value False
even when in the SQL statement the result is no records found.
Why will access not return the expected EOF and BOF status ?? ( I expected both to be True

I temporarily changed it to check for IsNull but I whanted to use BOF and EOF there

Can any one help me ??
[code]
Dim cnnDB As ADODB.Connection
Set cnnDB = CurrentProject.Connection
Dim rsDB As ADODB.Recordset
Set rsDB = New ADODB.Recordset
'Get CBPeriod
rsDB.Open "SELECT Min(AccntPeriods.AccPerID) AS CurrAccPerID FROM AccntPeriods WHERE ((AccntPeriods.Status)=""O"");", cnnDB
If IsNull(rsDB("CurrAccPerID")) Then
Form_Main.lblCBPeriod.Caption = "Error"
Else
Form_Main.lblCBPeriod.Caption = (rsDB("CurrAccPerID"))
End If
rsDB.Close
[/code]


Comments

  • GideonOmegaGideonOmega Posts: 617Member
    : I don't seem to be able to get MS Access to return the BOF and EOF property of the RecordSet rsDB
    :
    : I whant to check of the Returned recordset is Empty with EOF and BOF is True but somehow it keeps giving the value False
    : even when in the SQL statement the result is no records found.
    : Why will access not return the expected EOF and BOF status ?? ( I expected both to be True
    :
    : I temporarily changed it to check for IsNull but I whanted to use BOF and EOF there
    :
    : Can any one help me ??
    : [code]
    : Dim cnnDB As ADODB.Connection
    : Set cnnDB = CurrentProject.Connection
    : Dim rsDB As ADODB.Recordset
    : Set rsDB = New ADODB.Recordset
    : 'Get CBPeriod
    : rsDB.Open "SELECT Min(AccntPeriods.AccPerID) AS CurrAccPerID FROM AccntPeriods WHERE ((AccntPeriods.Status)=""O"");", cnnDB
    : If IsNull(rsDB("CurrAccPerID")) Then
    : Form_Main.lblCBPeriod.Caption = "Error"
    : Else
    : Form_Main.lblCBPeriod.Caption = (rsDB("CurrAccPerID"))
    : End If
    : rsDB.Close
    : [/code]
    :
    :
    :

    Try something Like this:

    [code]
    Dim cnnDB As ADODB.Connection
    Dim rsDB As ADODB.Recordset

    Set cnnDB = CurrentProject.Connection

    Set rsDB = New ADODB.Recordset
    'Get CBPeriod
    WITH rsDB
    .Activeconnection = cnnDB
    .CursorLocation = adUseClient
    .CursorType = adOpenForwardOnly
    .Source = "SELECT Min(AccntPeriods.AccPerID) AS CurrAccPerID FROM AccntPeriods WHERE ((AccntPeriods.Status)=""O"");", cnnDB
    .Open
    IF .EOF OR .BOF = True then
    Form_Main.lblCBPeriod.Caption = "Error"
    Else
    Form_Main.lblCBPeriod.Caption = (rsDB("CurrAccPerID"))
    End If
    .Close
    END WITH
    [/code]


    Hope this helps.
Sign In or Register to comment.