Results 1 to 6 of 6
  1. #1
    GUMUBIBI is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2009
    Posts
    6

    Combo box open reports

    Hi


    I'm using this code for a combo box used to open reports but it does not work. THe error message when i select a report from the combo is " The report name 'Screen.ActiveControl' you entered in eitherthe property sheet or macro is misspelled or refers to a report that doesn't exist".
    The code is used for the following situation:
    - i created a table with the name of the reports (table=Reports, column=Nume_raport)
    - then i created in a form the combo list with the code:

    Private Sub Combo0_AfterUpdate()
    On Error GoTo Combo0_AfterUpdate_Err
    If (IsNull(Screen.ActiveControl)) Then
    Exit Sub
    End If
    TempVars.Add "Nume_raport", "Screen.ActiveControl"
    If (CurrentProject.IsTrusted) Then
    Screen.ActiveControl = Null
    End If
    DoCmd.OpenReport TempVars!Nume_raport, acViewReport, "", "", acNormal
    TempVars.Remove "Nume_raport"

    Combo0_AfterUpdate_Exit:
    Exit Sub
    Combo0_AfterUpdate_Err:
    MsgBox Error$
    Resume Combo0_AfterUpdate_Exit
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why are you using that round about code. I see no reason to use any TempVars or any indirection.

  3. #3
    GUMUBIBI is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2009
    Posts
    6
    Quote Originally Posted by RuralGuy View Post
    Why are you using that round about code. I see no reason to use any TempVars or any indirection.
    To be sincere I found that piece of code and I used it. And I did it earlier this day. The only thing is I'm only a beginner in VBA coding and it's very hard for me for now.

    You see the real problem in the beginning was this: I wanted to create a sort of combo box to select from a specified report the selected value.

    For example I have a report for different agents looking like this:

    Name Sale1 Sale2
    a1 1 1
    a2 1 2
    a3 3 4


    All I want is to create a combo box with the agent name and when I select the agent name the report is created only with that agent.
    Sot of a filter on report. And I begun with this code and I tried to learn about it so I could use it in my real problem.


    I hope I was explicit in the matter.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  5. #5
    GUMUBIBI is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2009
    Posts
    6
    Quote Originally Posted by RuralGuy View Post
    Man you are a genious. That had indeed something that solved my problem. I forgot about the where clause in openreport statement and it worked like a charm. This thing finally solved my problem with a lot of reports and lists. Thank you.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That's great! Are you ready to use the Solved thread tool yet?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  2. Replies: 1
    Last Post: 06-04-2009, 07:43 AM
  3. Open a form using a query that references a combo
    By accessbobp646 in forum Access
    Replies: 1
    Last Post: 02-22-2009, 09:50 AM
  4. Replies: 0
    Last Post: 08-17-2008, 12:19 PM
  5. Using combo box to open another form
    By ladyairj23 in forum Forms
    Replies: 0
    Last Post: 06-02-2006, 07:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums