Moving PK to FK

JAKnudson

New member
Local time
Today, 02:51
Joined
Jan 8, 2013
Messages
7
I new to all of this and I tried to find what I need on other posts/forums but I can't seem to find anything i can use.

What I'm doing is opening a second form from a main form. When the form opens I want to write the value of the main form PK to the control on the second form.

I have established the relationship which works if i type in the PK value from the main form so I know that all works. I just can't figure out how to make this happen automatically.

I created a simple database that I have attached which demonstrates how everything is set up.

Any help is greatly appreciated.
 

Attachments

Use the OpenArgs argument of the OpenForm Method to pass the PK value to the new form. Then use the OnLoad event procedure of the new form to write the OpenArgs property to the control.
 
I moved the OpenArgs from the On Open event to the On Load event and it still won't write the value. If i manually type in the number, the relationship works as expected but for some reason I can't seem to make the OpenArgs work as I expect. There must be something I'm over looking. I don't want to have to always type in the PK from the main form/table.
 
I got it. This just shows me how much I have to learn yet. I need to understand when to use Me! vs Me..
 
I got it. This just shows me how much I have to learn yet. I need to understand when to use Me! vs Me..

It isn't so much a case of "Me! versus Me." as "!whatever vs .whatever"

The bang (!) stands for the default collection so in the case of the form (in the first instance), that means the Controls Collection.
eg Me!somecontrol

This expression default to meaning:
Me.Controls.somecontrol

The dot precedes Properties and Methods.
eg Me.OpenArgs

However the items in the Controls Collection are also exposed as Properties of the form object. Consequently the dot almost always works for everything. Moreover only the dot works with Intellisense.
 

Users who are viewing this thread

Back
Top Bottom