Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    Question Unanswered: Recordset runtime error

    Hello everybody

    I have written the event handler below. It is supposed to check for a possible null record set, before opening a report based on a query.

    Private Sub btnReport_Click()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("query_Anafora_bash_aitias_blabhs ")
    On Error GoTo no_record

    On Error GoTo 0
    Set rst = Nothing
    Set db = Nothing

    If IsDate(Me.From_Date) Then dtFrom_Date = Me.From_Date
    If IsDate(Me.To_Date) Then dtTo_Date = Me.To_Date

    If (Me.btnKakh_xrhsh) Then
    DoCmd.OpenReport "Anafora_bash_aitias_blabhs_kakh_xrhsh", acViewPreview
    DoCmd.OpenReport "Anafora_bash_aitias_blabhs_fysiologikh_f8ora" ,
    End If

    Exit Sub

    MsgBox ("Aai anYeceai aaanaoYo")

    End Sub

    Private Sub btnUpdate_Click()
    DoCmd.Close acDefault
    End Sub

    Private Sub Form_Load()
    Flag_From_Date = False
    Flag_To_Date = False
    End Sub

    The code fails with a syntax error at the statement

    Set rst = db.OpenRecordset("query_Anafora_bash_aitias_blabhs ").

    The error states that more arguments are need. I had the idea that all other arguments to the OpenRecordset method were optional. Is this not the case?
    Attached Thumbnails Attached Thumbnails flip-lid.gif  

  2. #2
    Join Date
    Mar 2004
    Glasgow, Scotland
    Try using querydefs:

    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim rst As DAO.Recordset

    Set db = CurrentDb()

    Set qdf = db.QueryDefs("QRY_CONTACT_Details")

    Set rst = qdf.OpenRecordset

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts