Passing data to a new entry in a second table (1 Viewer)

zebrafoot

Member
Local time
Today, 16:22
Joined
May 15, 2020
Messages
61
That looks logical. So I assume that I could substitute the code you have:

.txtSubjectF2 = me.txtSubjectF1
.txtMessageF2 = me.txtMessageF1

with ContactID/OrderID or whatever I wanted to pass?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:22
Joined
Jul 9, 2003
Messages
16,244
I would say that if you've got a field that ends in "ID" like "OrderID" then it is very likely that it is an auto number field generated automatically by Microsoft Access, which means you won't be able to update it, if that's what you're trying to do.
 

zebrafoot

Member
Local time
Today, 16:22
Joined
May 15, 2020
Messages
61
I would say that if you've got a field that ends in "ID" like "OrderID" then it is very likely that it is an auto number field generated automatically by Microsoft Access, which means you won't be able to update it, if that's what you're trying to do.

Appreciated. I merely want to use it a means of capturing a snapshot - so the ID fields (for example) would be a foreign key in the destination table.
 

June7

AWF VIP
Local time
Today, 08:22
Joined
Mar 9, 2014
Messages
5,423
Might be less confusing if you don't use ID in foreign key field name or maybe suffix field name, such as OrderID_FK.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:22
Joined
Feb 19, 2002
Messages
42,970
Having the FK field name be IDENTICAL to the PK it points to is not confusing. Using the ID suffix for non-PK/FK fields IS confusing. So using EmployeeID to refer to the employee number generated by some other application is confusing. Calling it EmployeeCode or EmployeeNum would be much more appropriate and allow you to have an EmployeeID which IS an autonumber and is used as the PK for the employee table in YOUR application. The EmployeeNum would be kept as data and printed as the identifier on all reports/forms but EmployeeID would be used internally as the PK and for the FK of all rellationships. EmployeeNum in the Employee table should be defined with unique index = yes but the autonumber should be the PK of the table.
 

mike60smart

Registered User.
Local time
Today, 16:22
Joined
Aug 6, 2017
Messages
1,899
Hi again,

Thanks for taking the time to respond again. Apologies if I wasn't clear enough in my original question - I am a new access user so I really want to understand the underlying methodology for passing data between tables.

Let me try to explain the thinking behind what I want my database to do - the example I gave initially seems to have led to some confusion, so can we pretend for a moment that I never mentioned subtables! subforms!

I have a database of customers/opportunities/quotes/products etc. When a customer quote is made, I wish to make a FIXED record in a new table of the relevant details (e.g. price, applicable taxes, discounts etc) so that changes to the underlying tables will not affect the record I have made in the new table. However, the example I give here is irrelevant really; I just want to know if a form contains >1 piece of information that I wish to replicate elsewhere, how would I code a command to record the relevant variables temporarily, open a different form and drop the passed information in. I can see that OpenArgs may be a way to do this, but I'm struggling to find a good reference on the process.

I hope that's a clearer explanation, but if not, please say.

Best wishes,
Pete
Hi Pete

Rather than trying to store the same information in different Tables why not have a Control in the Subform that Indicates what Type of Record it is.

It can be Either a "Quote" or "Confirmed Sale" etc...
 

Users who are viewing this thread

Top Bottom