Button on Form (1 Viewer)

EdwardsC

New member
Local time
Yesterday, 18:54
Joined
Jul 10, 2019
Messages
21
I need help on something that is beyond my Ms access knowledge. I have two tables; one is a Sampletbl and the other is a Test Resultstbl. The tables are one-to-one via SampleID. When I am on my Sample Form, I would like to click a button that moves me to my Test Results form to enter the results for the sample. These results would be for the current record I was on in my Sample form. I have tried to achieve this via macro but it's not working.
 

bob fitz

AWF VIP
Local time
Today, 02:54
Joined
May 23, 2011
Messages
4,718
I don't think you can do that with one to one tables. They are rarely used. Are you sure you have the right relationship. Why not just put all the fields in one table. Perhaps you actually should have a one to many relationship but with the information we have we can only guess.
 

plog

Banishment Pending
Local time
Yesterday, 20:54
Joined
May 11, 2011
Messages
11,638
First, 1-1 relationships aren't normal. Instead all the data goes into just 1 table. Right? You wouldn't have a PersonTable where you store PersonID, FirstName and LastName; and then have another table where you store PersonID and DateOfBirth. DateOfBirth would just go into the PersonTable. So please explain why you have a 1-1 relationship.

With that said, the way to open a form via button to a specific id is to use DoCmd.OpenForm:


Check out the WhereCondition section and see the examples. That argument is how you can limit what record(s) the form opens to.
 

EdwardsC

New member
Local time
Yesterday, 18:54
Joined
Jul 10, 2019
Messages
21
Thank you for the replies. Very helpful tips. The one to one relationship was not appropriate for this scenario for sure. Thank you for highlighting this :p I found the issue. I was missing the SetValue macro
Item = [Forms]![Samplefrm]![SampleID]
Expression = [SampleID]

Again, thank you for your support!
 

Users who are viewing this thread

Top Bottom