I have a simple form with 4 fields, and a subform that retrieves records that are potential matches based on a query.
The user will use the ID from the subform record and enter it into one of the fields on the main form (this is how the match will be stored).
Is there a way using a button/macro to populate the parent form's field with the ID of the subform record that is currently selected?
For example, the subform loads 7 records. The user highlights record 3, which shows 3 fields, one of them the PK. The user would then click this button, and one of the fields in the table the parent form is based on would be updated with the PK of the record selected in the subform.
Right now, they are manually copying & pasting, but it seems like I should be able to write a macro to do this.
Thoughts?
Thanks!
7 6141
To reference an item on the parent form you can use either Me.Parent.ControlName or Forms!FormName!ControlName
So if I want to pull the PK of the selected record on the subform, what would that be?
Forms!Form1!???
To reference an item on the parent form you can use either Me.Parent.ControlName or Forms!FormName!ControlName
Sorry, to be more explicit:
If I want Field1 of the SELECTED record in the subform, and to update the active record in the parent form...
Is the selected record something like:
Forms!Subform!Field1
Or is there some tag like ".selected" that I need in there?
I think once I have that, it's a matter of a simple update query that uses that item.
Thanks!
You can't do Forms!SubformName!ControlName
You can do Forms!ParentName!SubformName.Form.ControlName
However, if you're going to be in the subform anyways, it'd be easier to use Me.ControlName
So basically, if you want to set a field, MatchedKeyField, on the parent form using the PK field, PrimKeyField, of the subform, then in your code you would type: -
Me.Parent.MatchedKeyField = Me.PrimKeyField
-
OR
-
Forms!FormName!MatchedKeyField = Forms!FormName!SubformName.Form.PrimKeyField
-
OR any combination of the two.
-
You can't do Forms!SubformName!ControlName
You can do Forms!ParentName!SubformName.Form.ControlName
However, if you're going to be in the subform anyways, it'd be easier to use Me.ControlName
So basically, if you want to set a field, MatchedKeyField, on the parent form using the PK field, PrimKeyField, of the subform, then in your code you would type: -
Me.Parent.MatchedKeyField = Me.PrimKeyField
-
OR
-
Forms!FormName!MatchedKeyField = Forms!FormName!SubformName.Form.PrimKeyField
-
OR any combination of the two.
-
Thanks for the quick reply. I've got to be getting close, but I'm getting an error.
The name of the main form is "AssignIds". The field in that form to be updated is "NewID". The name of the subform is "Pass2 subform" and the Field to pull from (primary key) is "Field1". I wrote the below, but it is erroring out:
Forms!AssignIds!NewID = Forms!AssignIds![Pass2 subform].Form.Field1
Thoughts?
Thanks for the quick reply. I've got to be getting close, but I'm getting an error.
The name of the main form is "AssignIds". The field in that form to be updated is "NewID". The name of the subform is "Pass2 subform" and the Field to pull from (primary key) is "Field1". I wrote the below, but it is erroring out:
Forms!AssignIds!NewID = Forms!AssignIds![Pass2 subform].Form.Field1
Thoughts?
Nevermind!!! I'm an idiot...the field name wasn't Field1...I had aliased it in the query. Sorry and thanks for all your help!!!
Not a problem, good luck.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kunal |
last post by:
Hi,
I need some help on writing an update query to update "UnitsSold" field in
Products Table whenever I save a transaction. The transaction may contain
several "Subtransactions", one for each...
|
by: William Wisnieski |
last post by:
Hello Everyone,
Access 2000
I have a main form with a continuous subform. On the main form I have a
text box that references a field on the subform. What I'd like it to do is
show the value...
|
by: Earthling |
last post by:
Any help would be appreciated to solve the following simple problem that
I will describe.
***
There is a form called "red chocolate form".
The form has a particular subform field that has a...
|
by: Michelle |
last post by:
Hi all
I have used knowledge base article 112747 to improve my subforms
performance. I am using Access 97.
I have a main form where i put an extra textbox which concatenated
TeamID WeekNum...
|
by: Lyn |
last post by:
Hi,
I am working on a genealogy form. The only table (so far) lists everybody
in the family, one record per person. Each record has an autonum ID.
The parent form (frmMainForm) displays the...
|
by: Jim |
last post by:
I have a form which is based on a join query. The join relationship is one
to many. When a new record is added and the user enters a value for one of
the fields in the "many" records, I attempt...
|
by: emc_cos |
last post by:
I have a very nice parent child relationship happening between a main
form and 8 subforms.
The main form is the data entry point for a table that holds textual
data like names, notes and the...
|
by: bitsnbytes64 |
last post by:
Hi,
I have a form which contains a subform. Both are were creetd using the form wizard and are bound by the column IXO_NR (on two different tables), which is the control source for a textbox on...
|
by: Access Programming only with macros, no code |
last post by:
ERROR MESSAGE:
Could not update; currently locked by another session on this
machine.
BACKGROUND
I have the following objects:
Table1 - HO (which has about 51,000+ records)
Table2 -...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |