Using the same date in a field across sub forms

hazeleyre23

Registered User.
Local time
Today, 09:47
Joined
Apr 6, 2016
Messages
18
Hi,

  • My main form : Maintenance
  • Subform (within main form): UpdateAgentInfo
  • Form I want to populate the date onto: UpdateAgent.

What I want to be able to do is use the FromDate field from my subform to populate on my UpdateAgent form txtUpdate field when it is opened:

I have tried:

Code:
Forms![UpdateAgent].txtUpdateFrom = Forms![Maintenance]![UpdateAgentInfo]![ToDate]

However it does not do anything....

Can someone advise on what i am doing wrong please.

thanks
 
try
Code:
Forms!UpdateAgent.Form.txtUpdateFrom = Forms!Maintenance.UpdateAgentInfo.Form.ToDate
 
thank you. that works perfectly :)
 
Using that code, how do I add a day onto this.

So if the ToDate = 2016/04/04, how do I + a to this to get 2016/04/05.

Thanks
 
if your field is a date you can simply use +1 if you get an error use:
DateAdd("d",1,[fieldname])
 
Thanks, do i put this in the code or in the default value (from the properties sheet)? As when i put it in my VBA Code it says 'Expected: = '

thanks
 
Try:
Code:
Forms!UpdateAgent.Form.txtUpdateFrom = DateAdd("d",1,Forms!Maintenance.UpdateAgentInfo.Form.ToDate
)
 
Sorry, but If I wanted to find the Max ToDate would I just add it into the same formula or would this have to be done on it own.

The reason I want to find the Max ToDate is so it always picks the latest date.
thanks
 
Sorry, but If I wanted to find the Max ToDate would I just add it into the same formula or would this have to be done on it own.

The reason I want to find the Max ToDate is so it always picks the latest date.
thanks
So if are you saying that you no longer want to add one day to the date on your main form but want to add one day to the most recent date used in the table/query that ToDate is in then you could use the DMax() function to return that value and the DateAdd() function add one day to that. For syntax using DMax() see: http://www.techonthenet.com/access/functions/domain/dmax.php
 
sorry to be a pain!

Yes, I want to find the max ToDate then add one day onto this.

thank you for your help
 
Perhaps something like:
Code:
Forms!UpdateAgent.Form.txtUpdateFrom = DateAdd("d",1,DMax("ToDate","[COLOR="Red"]YourTable/QueryName[/COLOR]"))
YourTable/QueryName would need to be changed to your actual Table/Query name.
 

Users who are viewing this thread

Back
Top Bottom