none
Code working from One form but not the other RRS feed

  • Question

  • The report opens correctly from frmHorseInfo but not from frmInvoice, could it be that frmHorseInfo has a bound text box tbhorseID, where as frmInvoice has a unbound Combo box [cmbHorseID] that is its HorseID

    Thanks for any help.............Bob

    this is the error I am getting........

    Private Sub Report_Open(Cancel As Integer)

    If CurrentProject.AllForms("frmHorseInfo").IsLoaded Then
        Report.RecordSource = "SELECT Distinct tblInvoice.InvoiceDate,tblInvoice.InvoiceID AS InvoiceID," _
        & " tblHorseInfo.HorseID, funGetHorse(0,tblHorseInfo.HorseID,false) AS HorseNamed, [StableReturnDate] " _
        & " FROM tblInvoice,tblHorseInfo where tblHorseInfo.HorseID " _
        & " = tblInvoice.HorseID" _
        & " and tblInvoice.HorseID=" & Forms!frmHorseInfo![tbHorseID]
        Report_rptHorseExpenses.tbInvoiceDate.Visible = False
    ElseIf CurrentProject.AllForms("frmInvoice").IsLoaded Then
        Report.RecordSource = "SELECT Distinct tblInvoice.InvoiceDate,tblInvoice.InvoiceID AS InvoiceID," _
        & " tblHorseInfo.HorseID, funGetHorse(0,tblHorseInfo.HorseID,false) AS HorseNamed, [StableReturnDate] " _
        & " FROM tblInvoice,tblHorseInfo where tblHorseInfo.HorseID " _
        & " = tblInvoice.HorseID" _
        & " and tblInvoice.HorseID=" & Forms!frmInvoice![cmbHorseID]
        Report_rptHorseExpenses.tbInvoiceDate.Visible = False



    Debug.Print Report.RecordSource
    End If
        Debug.Print "Recordsource = " & Report.RecordSource
    End Sub

                

    xxx

    Monday, December 30, 2019 10:18 PM

Answers

  • It looks like the user hasn't selected a value from cmbHorseID on frmInvoice...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by TurnipOrange Tuesday, December 31, 2019 2:10 AM
    Monday, December 30, 2019 10:40 PM

All replies

  • It looks like the user hasn't selected a value from cmbHorseID on frmInvoice...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by TurnipOrange Tuesday, December 31, 2019 2:10 AM
    Monday, December 30, 2019 10:40 PM
  • Thanks Hans, used cbHorseName and it worked..........Regards Bob

    ElseIf CurrentProject.AllForms("frmInvoice").IsLoaded Then
        Report_rptHorseExpenses.tbInvoiceDate.Visible = True

        Report.RecordSource = "SELECT tblInvoice.InvoiceID AS InvoiceID," _
        & " qActiveHorseListFiltered.* FROM tblInvoice," _
        & " qActiveHorseListFiltered where qActiveHorseListFiltered.HorseID=tblInvoice.HorseID And " _
        & " tblInvoice.HorseID=" & Forms!frmInvoice![cbHorseName]

            

    xxx

    Tuesday, December 31, 2019 2:10 AM