Appending Date Entry...

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
scott0314
Newbie
Posts: 2
Joined: Thu Apr 12, 2012 2:48 pm

Appending Date Entry...

Post by scott0314 » Thu Apr 12, 2012 3:11 pm

I searched for "appending date entry on form" and come up with over 1600 results with about 1 out of ten having to do with date(s) at all!! So, after reading tons of the results, I decided to do the newbie thing and go ahead and post my issue (I am after all at work and have many other projects to work on!)... so here it is:

I have a program that retrieves data out of several database tables and prepares a report based upon the user's inputs. One of the inputs is a simple date entry form field in the format of: MM/DD/YYYY

The operator is to enter 6 days prior to today's date in the above field. For example:

Today's date is 04/12/2012
Operator enters 04/6/2012

I need this done automatically with this Macro Scheduler. I have the rest figured out(with the exception of one more item)...

There is one more field that gets populated by the operator. It is a drop-down selection of 5 items: Monday thru Friday.
The operator selects tomorrow's day and when it's Friday, the operator selects Monday, same for Sat and Sun. I was using MouseMove to the next coordinates and lclicking, but this means I would have to have a different script for each day, not to mention that this needs to be run for 12 different reports each day!

Can anyone help out a poor beginner IT tech?!? I know a tad of VB, so the VB datediff is where I think I need to head towards, I just don't know the details of that function very well...

Thank you soooo much for any assistance!

Scott

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Apr 12, 2012 7:57 pm

Try these. Let us know how it goes.

Code: Select all

VBSTART
VBEND
Let>DaysAgo=6
VBEval>Right("0" & Month(now-%DaysAgo%),2) & "/" & Right("0" & Day(now-%DaysAgo%),2) & "/" & Year(now-%DaysAgo%),ago
MDL>ago


VBEval>weekday(date),today
If>{(%today%>1)and(%today%<6)}
  Add>today,1
Else
  Let>Today=2
EndIf
VBEval>weekdayname(%today%),nextday
mdl>nextday

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Thu Apr 12, 2012 11:18 pm

Macro Scheduler 13 has DateAdd now.

Code: Select all

GetDate>today
DateAdd>today,D,-6,SixDaysAgo
mdl>SixDaysAgo

scott0314
Newbie
Posts: 2
Joined: Thu Apr 12, 2012 2:48 pm

Post by scott0314 » Fri Apr 13, 2012 3:31 pm

Rain -

That's what I ended up doing! Thanks!

Now, for DayOfWeek, appending that by 2 days so it looks like:

DayOfWeek>someVar
someVar2=someVar+2

if someVar2="3" //(Wednesday)
then
Press Down
Press Down
Press Down
Press Enter

elseif someVar2="4" //(Thursday)
then
Press Down
Press Down
Press Down
Press Down
Press Enter

Elsif someVar2="5' //(Friday)
then
Press Down
Press Down
Press Down
Press Down
Press Down
Press Enter

ElseIf someVar2="6" //(Monday)
then
Press Down
Press Enter

ElseIf someVar2="7" //(Tuesday)
then
Press Down
Press Down
Press Enter

Still struggling with it... will get it eventually!

Thanks!
Scott

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts