Display calculated value in textbox taking values from database and user inputs (1 Viewer)

pinky

Registered User.
Local time
Today, 05:21
Joined
Jul 6, 2009
Messages
29
Hi,
I am working with form created in ms access database. I have to implement the logic so I am not able to get the right approach.Here is my scenario.
I have to calculate a value and display in text box. The formula needs to take input from other text boxes, values from database and calculate. I have set of values in table (year, Income, additional income). Date and Number is user inputs in the form(text box controls). The formula which Final_textbox needs to display is
"[Income+Number(additional income)]*3 for the year specified in date text box.

Can anyone help me out to start on this. I have tried different approaches but stuck in between.

Thanks,
Pinky
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 22:21
Joined
Jan 20, 2009
Messages
12,859
Not really quite enough information for a difinitive answer but here are some potential pieces of the puzzle.

Your Final textbox will have a Control Source with a formula that starts with an equal sign.
This formula refers to the Value in other controls on the form simply by their name.
eg: = [control1]*[control2]

To get the value from a field in a record of a table based on a value of another field in the table being the same as a control on the form you can use a Domain LookUp expression.
Code:
DLookUp("wantedfieldname","tablename", "tablename.somefieldname=Forms!formname.controlname")

Join the pieces together and you will have your answer.
 

pinky

Registered User.
Local time
Today, 05:21
Joined
Jul 6, 2009
Messages
29
Hi,
Thanks for helping me.

I tried with domain look up by writing that in control source space in Data tab. I have tried with below one in control source of textbox in which I need FPG value according to the year filter.

=DLookUp("FPG","INCOME","INCOME.Year=Forms!frmCaseFileReview.YearIncome")

But it didnt work. When i enter 2009 in YearIncome text box it does not effect the other textbox. Its just select FPG from INCOME where year = &year. How can I implement this.

Thanks,
pinky
 
Last edited:

pinky

Registered User.
Local time
Today, 05:21
Joined
Jul 6, 2009
Messages
29
As such it is working when I entered code into control source property for the first time. If the year is already entered in year textbox then when i edit or refresh control source property for first time the corresponding value of income is displayed in income Textbox. So Do I need to configure something else for proper working.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 22:21
Joined
Jan 20, 2009
Messages
12,859
Requery the results textbox with the AfterUpdate event of the YearIncome box.

Me!resultstextboxname.Requery
 

pinky

Registered User.
Local time
Today, 05:21
Joined
Jul 6, 2009
Messages
29
I have added Me!Text203.Requery in After update event of IncomeYear Box where Text203 is name of results Textbox.

Here is the error which i got when I Updated year and clicked on results box to update.

ERROR: Microsoft Office can't find the macro 'Me!Texr203.'
The macro(or its group) doesn't exist or macro is new but hasn't been saved. note that when you enter the macrogroupname.macroname syntax in an argument, you must specify the name the macro's macro group was last saved under.
 
Last edited:

Users who are viewing this thread

Top Bottom