Results 1 to 4 of 4
  1. #1
    Newbie2 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Location
    Melbourne Australia
    Posts
    3

    Button to open form with a Where condition

    I am working with Access 2007 and have two Forms:


    Form 1- Patient Form (PatientNum)
    Form 2- Patient History (PatientNum)
    I have just viewed a great YouTube video on how to make a button Open a Form and go to a matching record using the Where Condition. I got it to work great, but it only works once when opening the new form from the navigation bar. It doesn’t seem to want to work while I have both forms opened. I have to close Form 2 and used the button on Form 1 to make the event happen.
    I am using a simple macro to open Form 2 with the following conditional statement.
    [PatientNum]= [Forms]![PatientForm]![PatientNum]
    Because I am entering lots of data I generally have both forms open and flip back and forth using the tabs. I would like, when I press the Open Form 2 button for the Patient Number to match the Patient Number on the form I am working on.
    Thanks.. you guys have never let me down
    Newbie2

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Have you considered a form/subform arrangement? http://office.microsoft.com/en-us/ac...010098674.aspx
    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.

  3. #3
    Newbie2 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Location
    Melbourne Australia
    Posts
    3
    Hi Super Moderator,
    Yes, I have, but i really would like to create the button. I will soon be adding more Forms and this will be a very helpful tool.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You flip back and forth using what tabs?

    More forms? Are they related to PatientForm? Could use a tab control and put each subform on a page of tab control.

    The trick is figuring out how to configure the form properties and what event to put code in to requery the second form when it is already open. I only use VBA.

    Set the Filter property of PatientHistory form to PatientNum=Forms!PatientForm!PatientNum and FilterOnLoad property to Yes. Then in the button Click event that opens the form:
    If CurrentProject.AllForms("PatientForm").IsLoaded Then
    Form_PatientHistory.Requery
    Form_PatientHistory.SetFocus
    Else
    DoCmd.OpenForm "formname"
    End If
    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.

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

Similar Threads

  1. cmd button to open form
    By stephaniehpcswf in forum Access
    Replies: 1
    Last Post: 02-23-2011, 04:46 PM
  2. Replies: 1
    Last Post: 09-27-2010, 04:27 AM
  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 a report with a date condition
    By Grooz13 in forum Reports
    Replies: 3
    Last Post: 08-02-2010, 02:35 PM
  5. Open Report or Form depending on condition
    By jheintz57 in forum Forms
    Replies: 5
    Last Post: 03-12-2010, 08:16 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