Solved

Synchronize  a floating form record to selections in Underneath form.

Posted on 2014-02-10
13
401 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 47

Expert Comment

by:Dale Fye (Access MVP)
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 34

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
 
LVL 84
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 47

Expert Comment

by:Dale Fye (Access MVP)
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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 34

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 34

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 84
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

708 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

17 Experts available now in Live!

Get 1:1 Help Now