form to form value (2 Viewers)

kitty77

Registered User.
Local time
Today, 15:10
Joined
May 27, 2019
Messages
710
I have a form (main) that has a command button that opens (bulk) another form (specific record) based on field [IDnumber].
How can I double click on a field on the bulk form and have it populate a field with that value on the main form?

I can make it work if it's on the same form but not to another form.

Main Form[Msamplenumber1] = Bulk Form[Bsampleid1]
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:10
Joined
Oct 29, 2018
Messages
21,447
Have you tried?

Forms!MainFormName.Msamplenumber1 = Me.Bsampleid1
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:10
Joined
Feb 28, 2001
Messages
27,128
The syntax you use to move data from one form to another depends on which form is doing the moving. If the forms are parent/child (in the sense that the child form is a subform) then there is one syntax to use. If the forms are co-equal there is another syntax to use. Which relationship applies here?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,203
NEVER dirty a form this way. When you dirty the form, that leads to confusion by the user and "empty" records being saved if you don't do proper validation. The other problem with doing this "push" is that it affects only ONE record on that form. If the user will be able to enter multiple rows on the form, NO OTHER row will have the proper FK set.

There are several valid methods. One is to "pull" the FK. To use this method, put the code in the popup form's BeforeInsert event. The BeforeInsert event runs only ONCE for each record and it runs immediately after the user types the first character in any field. The code would be:

Me.Bsampleid1 = Forms!MainFormName.Msamplenumber1

so, you are "pulling" the value when you need it AND every time it is needed rather than "pushing" it only once to the first record.
 

Users who are viewing this thread

Top Bottom