Avatar of Michael
Michael
Flag for Australia asked on

I would like to display the calculated field result from a query in a text box on the form

I have a Training details form which has a control, Training_Date text box and then a combo box Frequency which has a number of set days.  This is calculated in the query and I would like to have the result displayed in the form control Due_Date once the choice from the combo box is chosen.
This will then allow the value to be recorded in the table allowing for reports and queries on training due.  
I have tried a number of methods without any luck as yet.

Cheers
Microsoft Access

Avatar of undefined
Last Comment
Michael

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
als315

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Michael

ASKER
Many thanks for the reply
I placed your code in the update event for cboDue_Date and it still didn't work, I then put the Control Source for txtDue_Date as =[qryTraining Query]![Due_Date].  I am now displaying #Name? in the text box.

This is the code in the form module.

'Code to display calculated field from Training_Query in form

Private Sub cboFrequency_AfterUpdate()

 Me.[txtDue_Date] = Dateadd("d", [cboFrequency], Datevalue([txtTraining_Date]))
 
End Sub

Cheers
als315

May be you can prepare sample DB with this form and some dummy data in table?
Michael

ASKER
Hi als315
I have attached the database with some info though please excuse the errors as I am trying to fix them with another expert from this forum as we speak.

When you open the database if you close the error message and double click frmPPS_Training_Register the tabbed form will open and then click on the Training Details tab to see the Due Date text box.

Many thanks for your help.

Cheers
PPS-Employee-Training.accdb
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
als315

Look at sample. txtDue_Date field should be bounded if you like to store it in table. Change cboFrequency and you will see changes
PPS-Employee-Training-1.accdb
Michael

ASKER
Many thanks als315
The changes work well and update immediately allowing the user to view before saving the record.

Cheers
als315

Michael! You didn't select any my comment as an answer, so it will not be marked as a solution and no points will be assigned to it.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
als315

I propose to select comment #a41715737 as an answer
Michael

ASKER
Sorry for the mix up.
I accept #a41715737  as the solution.

Cheers