Button to create new form with same field. (1 Viewer)

fosterg100

New member
Local time
Today, 08:33
Joined
Nov 29, 2019
Messages
9
Hi
I am sure this is straightforward, just been going around in circles trying to figure this out.

I have a main form, with the main field being [REFERENCE], with this field being unique.

I just want a button on the main form to open a second form, that has the same field [REFERENCE], which will be a one to many relationship.
I am after the button to add a new record on the second form with the same field [Reference]

Have tried through code and queries, but nothing seems to work.

Can anyone point me in the right direction? Did a few databases a few years back, but this is the first one in a while.

Thanks in advance.
Foster.
 

fosterg100

New member
Local time
Today, 08:33
Joined
Nov 29, 2019
Messages
9
Hi Paul
Thanks for the reply.
That seems to show the records that match the info in both forms, but I am after the button to open the second form, with the [Reference] field already filed in.
Basically, the second form is a diary form, so will have multiple entries for each [Reference] field.

Sorry, should have made this clear from the start.

Thanks.
 

fosterg100

New member
Local time
Today, 08:33
Joined
Nov 29, 2019
Messages
9
I have just seen the link, on the link you sent me, apologies, will look at that..
 

plog

Banishment Pending
Local time
Today, 10:33
Joined
May 11, 2011
Messages
11,611
This really has 2 components--the data part and the form part. You first need to do some data work, then you can open the form correctly.

Lets call the second table and form tblB and frmB respectively:

Data - first you need to run an INSERT INTO query to put a new record in APPEND query to insert tblB. This will have the [REFERENCE] value you need and probably no other data. tblB should have an autonumber primary key ([ID_B]), after you run that query you need to get that value (most likely with a DMAX (https://www.techonthenet.com/access/functions/domain/dmax.php))

Form - with that [ID_B] value you know what record in tblB you want to open frmB to. You use that in value in the method pbadly provided you.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:33
Joined
Aug 30, 2003
Messages
36,118
You want to enter a new record in the second form? If so, try opening the form and using the argument to open it to a new record, then

Forms!SecondFormName.Reference = Me.Reference
 

fosterg100

New member
Local time
Today, 08:33
Joined
Nov 29, 2019
Messages
9
That's great, all sorted using both you guys help!!!

Thank you very much!

Foster.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:33
Joined
Aug 30, 2003
Messages
36,118
Glad you got it working.
 

Users who are viewing this thread

Top Bottom