Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Synchronize  a floating form record to selections in Underneath form.

Posted on 2014-02-10
13
Medium Priority
?
424 Views
Last Modified: 2014-03-28
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
Comment
Question by:Mohammad Alsolaiman
  • 6
  • 3
  • 2
  • +1
13 Comments
 
LVL 49

Expert Comment

by:Dale Fye
ID: 39848346
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
 
LVL 40

Expert Comment

by:PatHartman
ID: 39848524
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
 

Author Comment

by:Mohammad Alsolaiman
ID: 39849136
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 85
ID: 39849730
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
 

Author Comment

by:Mohammad Alsolaiman
ID: 39850054
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 39850132
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
 
LVL 40

Expert Comment

by:PatHartman
ID: 39850312
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
 

Author Comment

by:Mohammad Alsolaiman
ID: 39851228
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
 
LVL 40

Expert Comment

by:PatHartman
ID: 39851439
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
 

Accepted Solution

by:
Mohammad Alsolaiman earned 0 total points
ID: 39949661
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
 
LVL 85
ID: 39949947
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
 

Author Comment

by:Mohammad Alsolaiman
ID: 39950345
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
 

Author Closing Comment

by:Mohammad Alsolaiman
ID: 39961050
Thank to all of you
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

926 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