• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

Synchronize a floating form record to selections in Underneath form.

Hi:
How to make a floating form, where I can browse a specific record each time I chose it from a list of a records located on Underneath form.
Please tell me if there is a form properties I had to select.
Thanks in advance
0
Mohammad Alsolaiman
Asked:
Mohammad Alsolaiman
  • 6
  • 3
  • 2
  • +1
1 Solution
 
Dale FyeCommented:
Generally, this is done through code in a button or specific event of the "underneath form".

How are you displaying the information in the "underneath" form?  Is it in a list, continuous form, subform?

I like to use the Form_DblClick event for continuous forms and subforms that are either continuous or datasheet,  But I also generally include an Edit button in the main forms footer to allow the user to select a record and then click the Edit button to popup the form for editing.  To do that, you would use code similar to:
Private Sub cmd_Edit_Click

    docmd.OpenForm "PopupFormName",,,"[ID] = " & me.txt_ID

End Sub

Open in new window

You might consider adding the acDialog as the WindowMode argument (2nd to last in the Openform argument list) in order to prevent the user from doing anything else on the "underneath" form until the editing form is closed.

The specific criteria you would use in the Where argument of the OpenForm method depends on whether the primary key field (in this case I used an autonumber [ID] field) or whether you use some form of text value.  If you used text, that criteria string might look like:

"[ClientID] = '" & me.txt_ClientID & "'"

Note that I've encapsulated the value in the txt_ClientID control with single quotes.
0
 
PatHartmanCommented:
When you pass values using the Openargs, they are only refreshed when the form "Opens".  Therefore, add code to your click event on the list form to determine if the form is open.  If it is open, close it first.  Then when you open it, the data will be refreshed.

If the popup form uses a RecordSource query that references the FK value on the list form, then in the click event that selects a new record, you have to requery the RecordSource of the popup form to make it rerun its query.
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
Actually, I want the floating form to be open all the time. So the two forms will be open .
Whatever record I select from the underneath form, should appear directly in the floating form. I don’t need to close the popup form to select another record. No, the popup form will be open all over the time while I'm selecting records.
The underneath form is for selecting records only, while the popup form is for browsing the selected record for editing purposes.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Personally I'd do this with a standard mainform/subform. When the user selects a record on the mainform, the subform would show the record and the user could edit. IF you're using 2010, it includes a new "split form" that does exactly that - shows a list of records in one pane, and a detail view of the selected record in aother.

Or, if you must stick with the floating form methodology, you can include a property on the floating form that accepts the ID value of the record, and then look up and display that record on the floating form. Assuming your floating form is based on the same dataset as the underlying form, then add code like this to the floating form:

Public Property Let RecordID (ID As Double)
  Dim rst As DAO.Recordset
  Set rst = Me.RecordsetClone
  rst.FindFirst "YourIDField=" & ID

  If Not rst.NoMatch Then
    Me.Bookmark = rst.Bookmark
  End IF

  set rst = Nothing
End Property

Then call it from the underlying form like this:

Forms("FLoatingForm").RecordID = Me.MyRecordID
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
Actually my problem is, what floating form properties should I use, to allow me select and work on the underneath form while the floating form is still open and effected with my selections at once.
0
 
Dale FyeCommented:
Your challenge with keeping both forms open will be that they use similar recordsets, so if you make changes to the popup form, but don't save them and refresh the main "underneath" form, then you could end up with write conflict errors.
0
 
PatHartmanCommented:
Actually, I want the floating form to be open all the time.
That's nice but you never said how the popup was determining which record to open to.  I gave you two choices.  Are you using a third because HOW it get's the key it needs determines HOW to keep the two in sync.

When a form is opened, its recordset is instantiated.  New records can be added via the form but without rerunning the query new records added by others are NEVER shown.  You will see updates depending on your refresh rate but not new/different records.  Once you understand that, you will have a better idea of how to proceed.  I offered two options.  There are more.  You could even do as one poster suggested and use a subform rather than a popup form.  That is an excellent no-code solution.  But start by understanding the problem you are trying to solve.
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
For the first time, user should double click the desired record on the main form, the popup form will raise with this specific record.
After that, each time the user click a deferent record on the main form (remember the records displayed on list box) the synchronized popup form will display the new selected record. And so on.
0
 
PatHartmanCommented:
Then you want the popup form to use a query that references the list form for criteria.

Select ...
From ...
Where somefield = Forms!yourform!listcontrol.Form!somefield;

The above assumes that the list is a subform.  Change the reference if it isn't.

Then before you Open the popup form check to see if it is open.  If it is, requery it -
Forms!yourpopupform.Requey
If it is not open, then open it
Docmd.OpenForm "yourpopupformname"
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
Yes , the answer i was looking for is to not to open the floating form in dialog view .
I wasn't looking for how to determine the records
May be i couldn't describe my question well
Thanks for the try
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I wasn't looking for how to determine the records
That is EXACTLY what you were asking - how to synchronize your forms.

You failed to mention it was a dialog form. Had you done so, the first thing the Experts would have told you would be to NOT use the Dialog mode, since you are forced to work with the floating form exclusively.
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
In the main question I mention "form property"
" Please tell me if there is a form properties I had to select."

And in the discussion , I mention it again"
"Actually my problem is, what floating form properties should I use, to allow me select and work on the underneath form while the floating form is still open and effected with my selections at once."

I'm very sorry that I couldn't clear my need. Maybe as usual because of my poor English.
Sorry again for misunderstanding
0
 
Mohammad Alsolaimanapplication programmerAuthor Commented:
Thank to all of you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now