Query to auto populate another field in same record

CLCoop

Board Regular
Joined
May 30, 2018
Messages
56
Form called Input Allotments that shows the current funds of one state.
Subform that shows all that states transactions: master_data_auto_fiscal_year_subform based on a Query.
Query: Master_Data_auto_fiscal_year it has all the fields from the MasterData table
The query takes the date entered and breaks it down to Monthnum field, then a field called: FY: IIf([monthnum]<10,Year([DATE]),Year([DATE])+1) this gives me the fiscal year in field FY.

How do you get FY to auto populate FiscalYear field?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Use an Update Query.
See here: https://support.office.com/en-us/ar...ry-9dddc97c-f17d-43f4-a729-35e5ee1e0514#bmcr2

Note that it usually isn't necessary to store a value which can easily be calculated (as matter as fact, sometime it can violate the rules of data normalization, in that fields within a table should not be dependent on each other). If it can be calculated easy enough in a query, often storing them at the table level becomes totally unnecessary.
 
Last edited:
Upvote 0
[TABLE="width: 500"]
<tbody>[TR]
[TD]Field[/TD]
[TD]Monthnum: Month ([Date])[/TD]
[TD]FY: IIf([monthnum]<10,Year([DATE]),Year([DATE])+1)[/TD]
[TD]Date[/TD]
[TD]FiscalYear[/TD]
[TD]REVISED_ALLOTMENTS[/TD]
[/TR]
[TR]
[TD]Table[/TD]
[TD][/TD]
[TD][/TD]
[TD]Master_Data[/TD]
[TD]Master_Data[/TD]
[TD]Master_Data[/TD]
[/TR]
[TR]
[TD]Sort[/TD]
[TD]YES[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Show[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Criteria[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][CURRENT_ALLOTMENT]+[GS_INCREASE]-[GS_DECREASE]+[SB_INCREASE]-[SB_DECREASE]+[LEASING_INCREASE]-[LEASING_DECREASE][/TD]
[/TR]
[TR]
[TD]or:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][FY][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Nothing happens but asks me what I want FY to be when you run the query.
 
Last edited:
Upvote 0
You have to have a field pre set-up in your table to hold this value to hold this value (FY).
Then in your Update Query, you would place the calculation on the "Update To" line of this FY field.
If you look closely at the link I showed you, it shows you some examples and some example calculations.

You probably will also want to add criteria under this FY field to only update records where this field is empty (Is Null), so if you run this query multiple times, you are only updating new records that have a blank in this field.
 
Upvote 0
Ok I was able to update records based on Parent Child just had to manually type in each field I wanted to do. As well as there is a limit to how many parent/child relationships but it was enough to "auto fill" what I was looking for.

Go to the form, edit mode, click on the sub form you are wanting to auto fill based on form. go to Data. See the Link Master Fields and Link Child Fields. When you select this you get three boxes to link up. You can however add more fields by putting a ; with now spaces after the last field listed and keep adding. Remember to add the same to both Parent and Child if you skip one you may have data in the wrong field.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,150
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top