How do you display information in a form when the form is already open?

Posted on 2012-08-27
Last Modified: 2012-08-30
I have a form in a navigation form. On that form I have a custom search feature. When the user has typed in the info for the search criteria, how do I pass it to the form in the nav form instead of opening another form?
Is there something else other than OpenForm I could use?

Thank you,
Question by:Kennyboy5
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    Just curious...

    Why do you need a subform value to appear n the main (navigation) form.
    I just use navigation forms to "navigate"

    Beyond this, I would need to see a sample of your database.
    I don't know what this means:
    <When the user has typed in the info for the search criteria, how do I pass it to the form in the nav form >
    Pass what?.. the criteria, or the search result?
    Pass it to what form specifically...?

    Sample database notes:
    1. Back up your database(s).
    2. Combine the front and back ends into one database file.
    3. Remove any startup options, unless they are relevant to the issue.
    4. Remove any records unless they are relevant to the issue.
    5. Delete any objects that do not relate directly to the issue.
    6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
    7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
    8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
    9. Compile the code. (From the VBA code window, click: Debug-->Compile)
    10. Run the compact/Repair utility.
    11. Remove any Passwords and/or security.
    12. If a form is involved in the issue, set the Modal and Popup properties to: No
        (Again, unless these properties are associated with the issue)
    13. Post the explicit steps to replicate the issue.
    14. Test the database before posting.

    In other words, a database that we can easily open and immediately see and/or troubleshoot the issue.
    And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

    LVL 4

    Author Comment

    I have a navigation form called frmMainNav. One of the tabs in the navigation form display my main form called frmCOP. On frmCOP I have a search button that pops up a form with some fields like FirstName, LastName, DOB and when they populate any or all of the fields and hit the search button it finds the record (ClientID) and what I want it to do is display that record on the frmCOP within the frmMainNav. So I have the record but I don't know how to push it to the frmCOP in the frmMainNav. If I use DoCmd.OpenForm with just the frmCOP (without using frmMainNav) by itself it populates fine but because frmCOP is in a tab in the navigation form when I tell it to DoCmd.OpenForm to the frmMainNav it's prompting me for the ClientID. When I step through the code it does in fact have the ClientID which makes me believe that my syntax is not correct. Here is the code:
    Private Sub Command4_Click()
    Dim strFilter As String
        ' Set up the filter
        strFilter = "(ClientID = " & Me.txtClientID & ")"
        ' Open contacts filtered on the current row
        DoCmd.OpenForm FormName:="frmMainNav", WhereCondition:=strFilter
        ' Close me
        DoCmd.Close acForm, Me.Name
        ' Put focus on clients
    End Sub

    Open in new window

    Thanks again for responding,
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    Again, without a sample database I am at a handicap here.

    In the most basic sense you can just take the control values and reference them in another form.

    Something like this for the controlsource of the "FirstName" control on the main form:
    LVL 4

    Author Comment

    Here's the database. You'll need Access 2010 to open. There are only 3 records for testing purposes. Steps to produce my problem are as follows:
    1. Open up the frmMainNav form
    2. Click the 'binoculars' for search at the top of the COP form
    3. For the last name in the search window enter the name of 'Davis' (which has a ClientID of 2) and then hit the 'Search' button
    3. You'll get a popup saying that it found 1 client. Click yes to see the list.
    4. With the frmClientSearchResults now open, click on the record selector beside 'Rod Davis' and at the bottom click on 'View Details'

    It then prompts me for the ClientID and I'm not sure why. Even if I put in '2' for the parameter of Rod Davis it doesn't reflect back to the COP form in the frmMainNav.

    This is pretty much my problem.

    Thanks again,
    LVL 74

    Accepted Solution

    You are trying to open the Nav form based on ClientID
        DoCmd.OpenForm "frmMainNav", acNormal, , "ClientID=" & Me.[txtClientID]

    ...Yet the Nav form does not contain this filed/control...
    (The "SUB" form in the nave form contains this field....)

    If your main goal here is to filter the nav form for a certain Client , then you don't need the "Find" button,  and I don't really see a need to open another pop-up form.

    There is a combobox wizard that simply finds the record you select.
    See mi modified sample
    LVL 4

    Author Closing Comment

    Perfect! Thanks a lot for your help. I appreciate it

    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    Great, always remember, you can always ask our advice before creating design elements.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now