Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StringGrid

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
Hey peoples,

What I'm trying to do is have 6 checkboxes at the top of the screen, each of which refers to an option for field in a database.

When one or more is checked/unchecked, the StringGrid will only show the rows where the options is checked.
If you have only "Renting" and "Booking" selected then only the rows with either "Renting" or "Booking" in the Status field are shown.

Any ideas? This is the code that I currently have and it is not working, i can't tell why but i guess it has something to do with either the update StringGrid or the Where in the SQL.

Thanking you in advance,
Rick

Code:
procedure TForm1.ScheduleCheckBox(Sender: TObject);
var WhereThing : string;
begin
  If BoxRenting.Checked = True then
    WhereThing := '(((Booking.Status)="Renting" ';



  ScheduleADO.Close;
  ScheduleADO.SQL.Text := 'SELECT Booking.RentalNumber, Booking.PhoneCode, Booking.ClientName, Booking.Status, Booking.DatePickup, Booking.DateReturn ' + #13#10
                             + 'FROM Booking ' + #13#10
                             + 'WHERE ' + WhereThing + #13#10
                             + 'ORDER BY Booking.RentalNumber;';
  ScheduleADO.Open;
  ScheduleGrid.Repaint;
end;
 
Why do you use StringGrind other than DbGrid?

What's database?

try:

Code:
....
 WhereThing := 'Status = "Renting" '

....
ScheduleADO.SQL.Text := 'SELECT RentalNumber, PhoneCode, ClientName, Status, DatePickup, DateReturn FROM Booking WHERE ' + WhereThing + ' ORDER BY RentalNumber';

Giovanni Caramia
 
I think putting #13#10 in your query might cause problems, just leave those out and make sure you have spaces between the words (which you have anyway).

What error are you getting?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top