Copy text field from one form to another form upon open

  • Thread starter Thread starter Vince
  • Start date Start date
V

Vince

Hi,

Can someone help this newbie? I am fairly familiar with
the basics of MS Access. But just can't figure out where
to look for this one:

I have 3 tables OrderTbl, NoticeofBillingTbl,
NotAvailableTbl. These tables have a relationship of 1 to
1 (TO segregate the data instead of having one BIG flat
table)

The user will always begin data entry with the OrderTbl
but then they will choose whether the order will be
completed with NotAvailable or NoticeofBilling and not
both.

Because I set the primary keys the same for all tables and
a required field I would like to have the PK in the
OrderTbl to automatically copy and pasted into the
NoticeofBillingTbl or NotAvailableTbl when the user
request the table via a form.

Can Someone help!?

Thanks!
 
Vince,
I'm not clear of your reason for doing this the way you are,
however, you can pass data from one form to another by using
the OpenForm method's OpenArgs argument.

In the Main form event used to open the second form:

DoCmd.OpenForm "FormB", , , , , , [PrimeKeyField]

In FormB's Load event:

If IsNull(OpenArgs) Then
Else
Me![PrimeKeyField] = Me.OpenArgs
End If
 
Hi JohnFol,
Thx for the reminder, pls advise:

I am not using one table because of the options involved.
An OrderTbl will always be used to fillin requests but
then it may lead to selecting NoticeofBillingTbl or
NotAvailabeTbl.

Thus, if all fields were on one table their would be too
many empty columns right?

Please advise.

THX.
 
Hi Fred G.,
The reason I am doing this is to simply segregate the
tables because not all fields will be entered. But I
simply want a way to "COPY" the field in this case the
primary key field to the new table on OPEN and "Paste" the
information thus no manual entry.

I greatly appreciate your quick coding you must be a pro,
can you please guide me, I am a NEWBIE in vb coding...
I went to the button and used wizard to open the form 2
where do I insert your code?

OnClick -->Eventbuilder?
OnClick -->Expressionbuilder?

Do I just paste it in?
Sorry I am only on the first chapter of VBA coding.

Billion Thanks!

Vince
-----Original Message-----
Vince,
I'm not clear of your reason for doing this the way you are,
however, you can pass data from one form to another by using
the OpenForm method's OpenArgs argument.

In the Main form event used to open the second form:

DoCmd.OpenForm "FormB", , , , , , [PrimeKeyField]

In FormB's Load event:

If IsNull(OpenArgs) Then
Else
Me![PrimeKeyField] = Me.OpenArgs
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Vince said:
Hi,

Can someone help this newbie? I am fairly familiar with
the basics of MS Access. But just can't figure out where
to look for this one:

I have 3 tables OrderTbl, NoticeofBillingTbl,
NotAvailableTbl. These tables have a relationship of 1 to
1 (TO segregate the data instead of having one BIG flat
table)

The user will always begin data entry with the OrderTbl
but then they will choose whether the order will be
completed with NotAvailable or NoticeofBilling and not
both.

Because I set the primary keys the same for all tables and
a required field I would like to have the PK in the
OrderTbl to automatically copy and pasted into the
NoticeofBillingTbl or NotAvailableTbl when the user
request the table via a form.

Can Someone help!?

Thanks!


.
 
Vince,
To enter code for the Load event, open the that form's property sheet.
Click on the Events tab.
On the OnLoad line write:
[Event Procedure]
Then click on the button with 3 dots that will appear on that line.
When the event code window opens, the cursor will be positioned between 2
existing lines.
Type the code in between those lines.
Exit the code window.

Save the changes when you save the form.

The same will work when you need to code a control's event,
except you first must select that control.

Remember, the code I gave you uses generic table and field names.
Always substitute your actual names.

Hope this helps get you started writing code.

However, I'm not sure if your method is the best,
even assuming 3 tables are needed.
Have you thought about using a Main form based on OrderTbl,
with the other 2 forms, based on the other 2 tables, as sub forms.
If you link the Child and Master [ID] fields in all 3 forms,
all this will be done automatically.
No need to open the other forms, as they are already
displayed and linked on the Main form.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Vince said:
Hi Fred G.,
The reason I am doing this is to simply segregate the
tables because not all fields will be entered. But I
simply want a way to "COPY" the field in this case the
primary key field to the new table on OPEN and "Paste" the
information thus no manual entry.

I greatly appreciate your quick coding you must be a pro,
can you please guide me, I am a NEWBIE in vb coding...
I went to the button and used wizard to open the form 2
where do I insert your code?

OnClick -->Eventbuilder?
OnClick -->Expressionbuilder?

Do I just paste it in?
Sorry I am only on the first chapter of VBA coding.

Billion Thanks!

Vince
-----Original Message-----
Vince,
I'm not clear of your reason for doing this the way you are,
however, you can pass data from one form to another by using
the OpenForm method's OpenArgs argument.

In the Main form event used to open the second form:

DoCmd.OpenForm "FormB", , , , , , [PrimeKeyField]

In FormB's Load event:

If IsNull(OpenArgs) Then
Else
Me![PrimeKeyField] = Me.OpenArgs
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Vince said:
Hi,

Can someone help this newbie? I am fairly familiar with
the basics of MS Access. But just can't figure out where
to look for this one:

I have 3 tables OrderTbl, NoticeofBillingTbl,
NotAvailableTbl. These tables have a relationship of 1 to
1 (TO segregate the data instead of having one BIG flat
table)

The user will always begin data entry with the OrderTbl
but then they will choose whether the order will be
completed with NotAvailable or NoticeofBilling and not
both.

Because I set the primary keys the same for all tables and
a required field I would like to have the PK in the
OrderTbl to automatically copy and pasted into the
NoticeofBillingTbl or NotAvailableTbl when the user
request the table via a form.

Can Someone help!?

Thanks!


.
 
THANKS Fred!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I figured it out...wow your amazing, I hope to be at your
level of coding in a couple of years!!!
-----Original Message-----
Vince,
I'm not clear of your reason for doing this the way you are,
however, you can pass data from one form to another by using
the OpenForm method's OpenArgs argument.

In the Main form event used to open the second form:

DoCmd.OpenForm "FormB", , , , , , [PrimeKeyField]

In FormB's Load event:

If IsNull(OpenArgs) Then
Else
Me![PrimeKeyField] = Me.OpenArgs
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Vince said:
Hi,

Can someone help this newbie? I am fairly familiar with
the basics of MS Access. But just can't figure out where
to look for this one:

I have 3 tables OrderTbl, NoticeofBillingTbl,
NotAvailableTbl. These tables have a relationship of 1 to
1 (TO segregate the data instead of having one BIG flat
table)

The user will always begin data entry with the OrderTbl
but then they will choose whether the order will be
completed with NotAvailable or NoticeofBilling and not
both.

Because I set the primary keys the same for all tables and
a required field I would like to have the PK in the
OrderTbl to automatically copy and pasted into the
NoticeofBillingTbl or NotAvailableTbl when the user
request the table via a form.

Can Someone help!?

Thanks!


.
 
Back
Top