Results 1 to 9 of 9
  1. #1
    MadeCurler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Scotland
    Posts
    6

    Sleepless Combo Select not working on form

    I have a form with a combo box that has six values being pulled from a table "Catches 1 - 22 Salmon", "Catches 1 22 Sea Trout" plus another 4 values.


    I have six corresponding reports called "Cathces122Salmon", "Catches122SeaTrout" plus another 4 reports.


    What I want (obviously) is to open the report "Catches122Salmon" when I select "Catches 1 - 22 Salmon" from the combo


    When I use the code below on a command button, a report opens but it is not the one referred to in the If..Else statement. For example, If I select "Catches 1-22 Grisle" from the drop down it opens "Catches122SeaTrout"


    Private Sub Command5_Click()


    Dim strForm As String


    If Me.Combo6 = 1 Then
    strForm = "Catches122Grisle"

    ElseIf Me.Combo6 = 2 Then
    strForm = "Catches122Salmon"




    ElseIf Me.Combo6 = 3 Then
    strForm = "Catches122SeaTrout"

    ElseIf Me.Combo6 = 4 Then
    strForm = "Catches2332Grisle"

    ElseIf Me.Combo6 = 5 Then
    strForm = "Catches2332Salmon"

    Else
    strForm = "Catches2332SeaTrout"
    End If




    'Debug.Print strForm


    DoCmd.OpenReport strForm, acViewPreview


    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Add this right before the OpenReport

    Debug.Print Me.Combo6

    And see what it produces. My guess is that the combo doesn't return what you expect.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Also, can step debug. Set breakpoint, follow the code as it executes. Review link at bottom of my post.

    Show the combobox RowSource sql statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    MadeCurler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Scotland
    Posts
    6
    Thank you for that but I still have problems. When I add Debug.Print Combo6 at the beginning of the code and Debug.Print strForm at the end of the code I get weird results. For example if I select the first combo item I get Combo6 = 3 and strForm = CathchesSeaTrout in the immediate window. I would expect combo6 to =1 and strForm =Catches122Grisle




    Another example if I select the second item I get combo6 = 1 and strForm=Catches122Grisle in the immediate window. I would expect combo6= 2 and strForm = Catches122Salmon.


    I'm new to all this and it's now driving me mad!! I'd appreciate any help you can give.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    MadeCurler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Scotland
    Posts
    6
    Thank you very much for your kind offer but I'd be too embarrassed to do that. I'm an enthusiastic pensioner and I know my limitations. I'm trying hard to learn VBA from books and the WEB but it isn't easy (at 66). I quite enjoy it but this little project is driving me mad. Thanks again.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No need to be embarrassed; we've seen it all. It's just hard to debug sometimes without seeing it. What are the row source and bound column properties of the combo?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  9. #9
    MadeCurler is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Scotland
    Posts
    6
    I set the data source of the combo as a table called "TblPoolSelect" in which I set the Primary Key to PoolSelectId (Autonumber) and the only other field I listed in that table was "PoolSelectRange" in which I entered 6 values...ranging from "Catches 1-22 Salmon" to "Catches 23 - 32 Grisle".....I then created 6 queries using other properly "related" tables in the Db where one of the criteria was "PoolSelectRange" and subsequently reports based on each of the 6 queries. You suggested in your earlier reply that three fields should have been created (including PK)......namely PoolsSelectID, reportName, categoryName...and I now understand why (I think).

    My main problem with this was that I was too ambitious. I tried to present the data in a report driven , button "on click" interface without the need to use the Access menu system (like File>Print Query).....I found a tutorial on the web at.....

    http://www.datapigtechnologies.com/f...earchform.html

    ....that suits me fine and works (although it's not as fancy as I'd like as far as producing customised reports is concerned)...

    I really appreciate your help and understanding on this, but please don't put yourself to any more bother.

    Kind Regards

    MadCurler

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

Similar Threads

  1. Using form combo box in query to select date.
    By LordNecro in forum Access
    Replies: 2
    Last Post: 04-14-2012, 05:09 AM
  2. Replies: 2
    Last Post: 08-18-2011, 10:20 PM
  3. Working of Combo boxes in Form
    By suryaprasad in forum Forms
    Replies: 3
    Last Post: 06-29-2011, 11:54 AM
  4. Replies: 1
    Last Post: 05-05-2011, 09:21 AM
  5. Combo-box to select item to edit in Form
    By DHavokD in forum Forms
    Replies: 7
    Last Post: 06-05-2009, 01:39 PM

Tags for this Thread

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