Using the same date in a field across sub forms (1 Viewer)

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
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
 

leanpilar

Registered User.
Local time
Today, 01:14
Joined
Aug 13, 2015
Messages
94
try
Code:
Forms!UpdateAgent.Form.txtUpdateFrom = Forms!Maintenance.UpdateAgentInfo.Form.ToDate
 

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
Joined
Apr 6, 2016
Messages
18
thank you. that works perfectly :)
 

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
Joined
Apr 6, 2016
Messages
18
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
 

leanpilar

Registered User.
Local time
Today, 01:14
Joined
Aug 13, 2015
Messages
94
if your field is a date you can simply use +1 if you get an error use:
DateAdd("d",1,[fieldname])
 

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
Joined
Apr 6, 2016
Messages
18
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
 

bob fitz

AWF VIP
Local time
Today, 00:14
Joined
May 23, 2011
Messages
4,726
Try:
Code:
Forms!UpdateAgent.Form.txtUpdateFrom = DateAdd("d",1,Forms!Maintenance.UpdateAgentInfo.Form.ToDate
)
 

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
Joined
Apr 6, 2016
Messages
18
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
 

bob fitz

AWF VIP
Local time
Today, 00:14
Joined
May 23, 2011
Messages
4,726
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
 

hazeleyre23

Registered User.
Local time
Yesterday, 16:14
Joined
Apr 6, 2016
Messages
18
sorry to be a pain!

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

thank you for your help
 

bob fitz

AWF VIP
Local time
Today, 00:14
Joined
May 23, 2011
Messages
4,726
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

Top Bottom