Transfer data from current record into a subform (1 Viewer)

ErinL

Registered User.
Local time
Yesterday, 22:59
Joined
May 20, 2011
Messages
118
Hello everyone -

I have a form which contains a subform. On this subform, the user will enter several lines of container ID numbers. If one of these containers has errors, they check a yes/no box and a pop up form opens for them to enter the details of the errors.

I want two fields that are populated on the subform to transfer information to the corresponding two fields on the pop up form. This works when only one container ID has been added to the subform. However, when there are multiple containers in the subform and the container with the errors happens to be the second or third record on the subform, the pop up form always transfers the information from the first record to those fields.

I also have the subform requerying when the check box is checked so that the information saves to the table and the focus does stay on the correct record but the pop up form still opens with the wrong information.

Can someone tell me how to transfer the information from the record that the user is currently on?

Thank you in advance! :)
 

missinglinq

AWF VIP
Local time
Yesterday, 23:59
Joined
Jun 20, 2003
Messages
6,423
Where is this Checkbox... on the Main Form? On the Subform Header? On each Record of the Subform?

Linq ;0)>
 

ErinL

Registered User.
Local time
Yesterday, 22:59
Joined
May 20, 2011
Messages
118
Hi Linq -

The checkbox is on each record of the subform.
 

missinglinq

AWF VIP
Local time
Yesterday, 23:59
Joined
Jun 20, 2003
Messages
6,423
Gien that, I guess we need to see the exact code you're currently using to do this. Even better would be attaching a copy, saved in 2007 format (2003 would be even better!) of your file to a post.

Linq ;0)>
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 13:59
Joined
Jan 20, 2009
Messages
12,854
There are a few ways to make a popup form match the records in another form. What works depends on your data structure.

1. Set the Recordset property of the popup to the Recordset of the calling form. This works well if you are simply opening a single form to add more detail to records that are shown in Datasheet or Continuous Forms on the calling form. The popup will open at the current record of the calling form.

You would need to include the error description field in the Recordsource of the calling subform but there is no need to display it on that form.

2. Implement the popup form as a subform of another otherwise empty form. Enter the MasterLinkFields property of the subformcontrol as the key field on the calling form using the full reference via the Forms collection.

The popup then behaves as though it is a subform on the calling form except it does not automatically track the current record on the calling form until it is requeried.

3. Pass the key from the current record of the calling form as the OpenArgs argument of the OpenForm method that opens the popup form. Then use the BeforeInsert event of the popup form to read the OpenArgs Property and write it to the key field of new records.


BTW If the checkbox is stored in the table then you might have a normalization error. If the presence of the error description could indicate that there is an error then there should not be a stored checkbox.
 

Users who are viewing this thread

Top Bottom