Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    currenproject is loaded in report does not work (2007)

    Edited by HansV to change <!t>[script] and <!t>[/script] tags to <!t>
    Code:
     and <!t>
    - script is hardly readable.


    I have the folowwing code in my on open report:
    When I open form2 there is no problem, when I open form1 it is like access does not see that the form is open.
    Can someone help me please?

    <code>Private Sub Report_Open(Cancel As Integer)
    Dim WhiCh
    If CurrentProject.AllForms("form1").IsLoaded = True Then
    WhiCh = Forms!form1!cmbZoek
    ElseIf CurrentProject.AllForms("form2").IsLoaded = True Then
    WhiCh = Forms!form2!CmbFactnr
    Else
    DoCmd.Close
    End If
    Me.RecordSource = "SELECT * from qryfactnr " & _
    "WHERE (tblfactuur.idfactuur)= " & WhiCh
    End Sub</code>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: currenproject is loaded in report does not work (2007)

    Do you get an error message? If so, what does it say?

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: currenproject is loaded in report does not work (2007)

    The error is just that he can't fiend the field from form2.
    But he does not need form2 because form1 is loaded.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: currenproject is loaded in report does not work (2007)

    Try this:

    ...
    If CurrentProject.AllForms("form1").IsLoaded = True Then
    WhiCh = Forms("form1").Controls("cmbZoek").Value
    ElseIf CurrentProject.AllForms("form2").IsLoaded = True Then
    WhiCh = Forms("form2").Controls("CmbFactnr").Value
    Else
    ...

    Hopefully this doesn't generate an error if a form is not open.

  5. #5
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: currenproject is loaded in report does not work (2007)

    That works to and believe or not my code to.
    It was my stupid mistake. I was forgotten that in my query itself asked for that one form.
    Everything is alright now :-)

Posting Permissions

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