Results 1 to 8 of 8
  1. #1
    jwill is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2012
    Location
    MD
    Posts
    67

    Trying to use a macro to load a form dynamically

    Hello,



    Windows Vista
    Access 2007

    This is my first post here and I need a little help. I'm trying to load a form dynamically and it doesn't seem to be working. I'm using the OpenForm macro and in the "Where condition" field I'm using '[Forms]![toddler_times]![student_id]=[Forms]![bathroom_chart]![bt_student_id]'. When the form loads it doesn't load any of the corresponding records (and yes there are records in the table ) Any help would be greatly appreciated.

  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,640
    The format is

    FieldName = Value

    so try

    [student_id]=[Forms]![bathroom_chart]![bt_student_id]

    Here's the VBA method/syntax:

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

  3. #3
    jwill is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2012
    Location
    MD
    Posts
    67
    Thanks alot Paul I used the VB code and I'm almost there. It's asking me to enter the bt_student_id parameter. I was looking for it to use the value student_id in the first form instead of me having to input it. Any ideas?

  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,640
    Either that form isn't open or the form or control names are misspelled.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jwill is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2012
    Location
    MD
    Posts
    67
    IT WORKED!! I was referencing the control on the form rather than the column in the underlying table. Thanks so much! Will the same method work on subforms?

  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,640
    You can refer to a subform for the value, sure. You can't filter one that way, if that's what you mean.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    jwill is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2012
    Location
    MD
    Posts
    67
    Yes that's what I meant, but that's ok, I'll stay away from the subform. Thanks again

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Form Load Time
    By bmschaeffer in forum Forms
    Replies: 1
    Last Post: 10-27-2011, 10:35 AM
  2. Form with Label captions that size dynamically
    By karmacable in forum Forms
    Replies: 3
    Last Post: 09-26-2011, 10:09 PM
  3. Run macro on form load?
    By stu_C in forum Forms
    Replies: 3
    Last Post: 08-16-2011, 07:54 AM
  4. Replies: 2
    Last Post: 06-01-2011, 09:32 AM
  5. On Load, form not visible
    By Bruce in forum Forms
    Replies: 15
    Last Post: 02-24-2010, 04:06 PM

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