Board index » off-topic » Newbie question - Printing single record reports

Newbie question - Printing single record reports


2004-04-21 11:17:18 AM
off-topic15
Using delphi 7 with the bde and paradox 4.0 tables.
I'm trying to figure out how to pass the current record to a report
previewer. The table containing the information has a keyed field "Tag#".
When the user views that tag# in a form, edits, browses memo fields, etc,
how can I pass the value of the tag# field to quickreport in order to print
only that tag number, and not all 15,000+ of them ?
I've used the following code in order to allow the user to input a value for
the tag# , but can't figure out how to do it without the user having to
enter a value.
procedure TfmRepairReportOptions.btnPrintRepairFormClick(Sender: TObject);
var
TagNo: String;
procedure Handler(Message:String);
begin
ShowMessage(Message + ' Try Again.');
eTagNo.SetFocus;
end;
begin
with dmRepairsReport.tbRepairs do
begin
SetKey;
FieldByName('TAG#').AsString:=eTagNo.Text;
GotoKey;
TagNo:=eTagNo.Text;
if (TagNo < '100') or (TagNo>FieldByName('TAG#').AsString then
raise ERangeError.Create('Tag Number does not exist!')
else
begin
try
Windowstate:=wsMinimized;
fmPrintRepairForm:=TfmPrintRepairForm.Create(Self);
fmPrintRepairForm.QuickRep1.Preview;
finally
Windowstate:=wsNormal;
fmRepairReportOptions.Close;
fmPrintRepairForm.Free;
end;
end;
end;
end;
Obviously I wouldn't have to use the If greater than, less than statement,
because the tag number does exist, because the user is currently viewing it,
but I'm not sure how to change the rest.
Thanks in advance.
 
 

Re:Newbie question - Printing single record reports

Hi,
Use a TQuery as the Datasource for your Report and pass the
SQL to the Report form ( on form creation ) specifying ( in
the where clause ) the 'Tag' you want to print.
HTH
Antonio
 

Re:Newbie question - Printing single record reports

Hi,
Is very easy, just create your report and leave QuickReport1.Dataset
empty. When you navigate to the correct record the user
hits a button which does QuickReport_YourReport.Preview or
QuickReport_YourReport.Print
That's the easiest way....At design time you may connect a Ttable
to QuickReport1.Dataset but make sure it's empty when saving
it. I use this option always and works fine.
greetings Peter
"Kendra" < XXXX@XXXXX.COM >schreef in bericht
Quote
Using delphi 7 with the bde and paradox 4.0 tables.
I'm trying to figure out how to pass the current record to a report
previewer. The table containing the information has a keyed field "Tag#".
When the user views that tag# in a form, edits, browses memo fields, etc,
how can I pass the value of the tag# field to quickreport in order to
print
only that tag number, and not all 15,000+ of them ?

I've used the following code in order to allow the user to input a value
for
the tag# , but can't figure out how to do it without the user having to
enter a value.

procedure TfmRepairReportOptions.btnPrintRepairFormClick(Sender: TObject);
var
TagNo: String;
procedure Handler(Message:String);
begin
ShowMessage(Message + ' Try Again.');
eTagNo.SetFocus;
end;
begin
with dmRepairsReport.tbRepairs do
begin
SetKey;
FieldByName('TAG#').AsString:=eTagNo.Text;
GotoKey;
TagNo:=eTagNo.Text;
if (TagNo < '100') or (TagNo>FieldByName('TAG#').AsString then
raise ERangeError.Create('Tag Number does not exist!')
else
begin
try
Windowstate:=wsMinimized;
fmPrintRepairForm:=TfmPrintRepairForm.Create(Self);
fmPrintRepairForm.QuickRep1.Preview;
finally
Windowstate:=wsNormal;
fmRepairReportOptions.Close;
fmPrintRepairForm.Free;
end;
end;
end;
end;

Obviously I wouldn't have to use the If greater than, less than statement,
because the tag number does exist, because the user is currently viewing
it,
but I'm not sure how to change the rest.

Thanks in advance.




 

{smallsort}