Link to home
Start Free TrialLog in
Avatar of Kennyboy5
Kennyboy5Flag for Canada

asked on

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

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,
KB5
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

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...?
...etc

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, ...post 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.

JeffCoachman
Avatar of Kennyboy5

ASKER

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
    Forms!frmMainNav.SetFocus
End Sub

Open in new window


Thanks again for responding,
KB5
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.
Yourmainform.Control=YourSubform.control

Something like this for the controlsource of the "FirstName" control on the main form:
=Forms!YourSubform!txtFirstName
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,
COP.accdb
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect! Thanks a lot for your help. I appreciate it

KB5
Great, always remember, you can always ask our advice before creating design elements.

;-)

Jeff