Hello Everyone
Today we are looking at the first two lines of our punch list.
Clock Calendar
Set font color on buttons to Red if there are task, notes or appointments scheduled for that day. Set Quick Note entry form to allows continuous entry.
Watch the short video below then come back to see how the code was created.
Well as you can see from the video the code is fairly simple and the application of this type of data mining is limited only to your imagination.
Lets look at our code for changing the button font to red if there are activities or appointments.
startdate = ctod(padl(alltrim(str(month(ActDate))),2,"0")+"/01/"+alltrim(str(year(ActDate))))
startnum = dow(ctod(padl(alltrim(str(month(ActDate))),2,"0")+"/01/"+alltrim(str(year(ActDate)))))
FOR i = 1 to 42 step 1
daynum = padl(alltrim(str(i)),2,"0")
eval("Button"+daynum+".text") = alltrim(str(day(startdate-startnum+i)))
BtnList[i] = dtoc(startdate-startnum+i)
if month(startdate-startnum+i) = month(startdate)
eval("Button"+daynum+".font.color") = "dark blue"
else
eval("Button"+daynum+".font.color") = "gray-50"
end if
if day(startdate-startnum+i) = day(ActDate) .and.month(startdate-startnum+i) = month(ActDate)
eval("Button"+daynum+".Border.Style") = "Small-Rounded-Indented"
eval("Button"+daynum+".Activate()")
end if
dim rec_count as N
dim ckdate as D
ckDate = startdate-startnum+i
rec_count = tablecount("activity","DTOC(Cont_Date) = '" +DTOC(Var->ckDate)+ "'")
if rec_count >= 1 then
eval("Button"+daynum+".font.color") = "Red"
end if
NEXT
The code above is the array we used to build our calendar buttons. The code we added is at the end of our function starting with
dim rec_count as N
and it uses
tablecount.()
to check to see if there are any records in the activity table which match the button date assigned by the array. Since the array steps through all 42 buttons, the result is each day that has activities is now red. Pay careful attention to the syntax used to pass the variable to the table count function.
Next we used stored values in the table to build a record list which was then used to filter the current table. This is done on the Quick Note Entry form on the on change events for the search variables. Lets look at the code on the Contact variable.
DIM records_found as N
records_found = topparent.queryrun("contact_id = Var->xContact","invert(cdate(date_enter))","","No","<Cross Level>",.f.)
Here we use query.run and pass the user choice to our function which filters the records in the table displaying what the user requested. Each of our variable filters work the same way. Simple and neat.
Well that’s it for today’s session. I hope you found it informative. Thanks again for stopping by and Remember, if you need help with an Alpha Software application or wish to inquire about a custom application for your business go to our website
and inquire or contact
NLawson@cdc-TakeCharge.com
Have a great day.
Leave a comment