Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    May 2011
    Posts
    22

    Button to open form with relative information...

    Here is my DB:


    Attachment 3367
    What I am trying to figure out is the best way to have, when the button is pressed, class form open with ONLY classes relative to the session selected. How can I do this?

  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,652
    See if this works for you:

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    May 2011
    Posts
    22
    I'm not exactly sure how to use that code for my form. Did you look at my form? What I want is for when Session 1 is chosen from the drop-down, all classes in that session will appear (either on that form or by opening a new form...)

    How would I apply your code for this?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can either use the Where Condition argument in your existing macro, or replace the macro with the VBA code equivalent, which is what I have in the link. If you're unsure how to put in VBA code:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    May 2011
    Posts
    22
    I'm still unsure of how to make your code work with my DB. Would this be correct?

    DoCmd.OpenForm "Classes", , , "Session = '" & Me.Still not sure what to put here??? & "'"

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Me.TheNameOfTheControlContainingTheSession

    Control means textbox, combo, etc.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Join Date
    May 2011
    Posts
    22
    Okay...
    Now here's my problem. I have the button set (thanks to your help!) to open the Classes form. But it's opening the form with ALL classes, even though I enter the parameter value for Session 1 when it opens. I only want it to make available classes that are in the desired session. How do I do this?

  8. #8
    Join Date
    May 2011
    Posts
    22
    Here's is my DB:
    Attachment 3371

  9. #9
    Join Date
    May 2011
    Posts
    22
    I need it to open the classes within the selected session... when those are opened, I want to have a list box to choose a class period (Period 1, Period 2, Period 3, or Period 4) and for that command to, in turn, make available only the classes within that period.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You get the parameter prompt because there is no session field in the data source of the classes form. I don't know your data well enough to know the relationship, but this technique requires the field be in the source (that's the only way it can filter it).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Join Date
    May 2011
    Posts
    22
    I put it in and now the form shows nothing when I open it...

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Put what in? As I see it, there's no way for the program to know what classes are associated with what session. I'd expect a session field in the classes table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    Join Date
    May 2011
    Posts
    22
    Disregard my last post...

    Yeah, that's what I was thinking. I added Session and Period to the Classes table. This should allow me to filter which appears on the class form that opens, correct?

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes; once the source of the classes form includes a session field, that code should work. If you use a numeric ID field like in the sessions table, it would be:

    DoCmd.OpenForm "Classes", , , "Session = " & Me.Session

    Intriguing name by the way. I'm married to a DarkAndLovely woman.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    Join Date
    May 2011
    Posts
    22
    How funny. My name is based off a piece of poetry back from the Bible days, lol.

    Anyway, there's a problem. Here's the code I have entered for my button:
    DoCmd.OpenForm "Classes", , , "Session = '" & Me.Session & "'"

    When I click I get the error message: "Run-time error '3464': Data type mismatch in criteria expression.

    What to do?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 03-03-2011, 03:56 PM
  2. cmd button to open form
    By stephaniehpcswf in forum Access
    Replies: 1
    Last Post: 02-23-2011, 04:46 PM
  3. Use a command button to open a form
    By johnpaul in forum Forms
    Replies: 24
    Last Post: 09-23-2010, 12:29 PM
  4. Open Form with information from previous form
    By jheintz57 in forum Forms
    Replies: 9
    Last Post: 03-23-2010, 07:30 AM
  5. Replies: 3
    Last Post: 10-16-2009, 07:54 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