help
I have an accounting program that uses FR 4.9.95 built in and we can add and design custom reports
What I want to do is use the input box to get a date from the user then pull all records for this date.
what I have done and does work is ;
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
IF <orders."ORDDATE"> =<Date>
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
this reports works well for today and we run it at the end of each day...but sometimes we forget or another user works late and place an order
what I am trying to do is
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
var Mydate :date;
mydate = inputbox; [/color] this is what I need to get right
begin
IF <orders."ORDDATE"> =mydate and not sure if calling my variable is correct here ?
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
I have downloaded all manual but cannot find one that gives the correct usage
If someone can help here or point me to a better manual for Pascal great, really appreciate this.
There are no controls to use for this, limited by the authors of the accounting package I guess
Larry
What I want to do is use the input box to get a date from the user then pull all records for this date.
what I have done and does work is ;
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
IF <orders."ORDDATE"> =<Date>
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
this reports works well for today and we run it at the end of each day...but sometimes we forget or another user works late and place an order
what I am trying to do is
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
var Mydate :date;
mydate = inputbox; [/color] this is what I need to get right
begin
IF <orders."ORDDATE"> =mydate and not sure if calling my variable is correct here ?
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
I have downloaded all manual but cannot find one that gives the correct usage
If someone can help here or point me to a better manual for Pascal great, really appreciate this.
There are no controls to use for this, limited by the authors of the accounting package I guess
Larry
Comments
but you must convert the inbutbox result to a tdatetime as it is returning a string.
in design mode on the codepage
at the top of the page declare your variable this makes it global to all procedures
and in the bottom
begin
end.
block write code to set the value this block of code is the first script to run
sample
var
mydate:tdatetime;
begin
mydate:=strtodate(InputBox('Date entry','in the format mm/dd/yyyy','02/28/2010'));
end.
or you can use dialog form and a dateedit control
while waiting for a reply here I worked that out and was 1st using a string to get the user input then the strtodate to get a valid date.
your line shortens my code so added in place of my 3 lines and 2 variables..nice
but still have 2 problems
1 the showmessage ( mydate) taking the default of '18/11/2010' gives me a numeric number of 40500 ??confusing me
and
2 if I try to replace the line IF <orders."ORDDATE"> =<date> with IF <orders."ORDDATE"> = <mydate> I get an error at end of report that say's mydate is undeclared so assume its because it was declared in another procedure
tried adding it at the bottom between the begin and end. but keeps asking for a ;
where do I create the variable that is global ?
my script thus far
procedure ReportOnStartReport(Sender: TfrxComponent);
var
mydate:tdatetime;
begin
mydate:=strtodate(InputBox('Date entry','in the format dd/mm/yyyy','18/11/2010'));
showmessage( mydate ); ' just for my check returns 40500
end;
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
Begin
IF <orders."ORDDATE"> =<mydate> ' problem here not picking up mydate
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
not within a procedure (local) when the procedure is finished so is the variable.
When you use typed variables in code you do not need <> just the variable name.
only when you use categorized variables(expressions or datafields) do you need to use the <>
showmessage( mydate ) should be
showmessage(datetostr(mydate));
thanks you are a star my report now works perfectly after finally working out how pascal works logically and now defaults to todays date or user can now change it.
what would be nice now would be to have an error routine that checks for a valid date before running the procedure and allow the input box to be reshown to corrrect the date.
any idea on this?
does Pascal have something like on error goto ?
my script
var
mydate:tdatetime;
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
Begin
IF <orders."ORDDATE"> =mydate
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
begin
mydate:=strtodate(InputBox('Date entry','in the format dd/mm/yyyy',<Date>));
end.
there is no goto in pascal but there is a try except finally construct.
Just for your info you could write this differently
IF <orders."ORDDATE"> =mydate
THEN MASTERDATA1.VISIBLE:= TRUE
ELSE MASTERDATA1.VISIBLE:= FALSE;
end;
shortform syntax
masterdata1.visible := (<orders."date"> = mydate);
my own prefrence would be to add a dialog page to the report with a datedit control
and 2 buttons ok cancel