here is an example of my script
var
sUser: string = '';
sLocation: string = '';
procedure Settings_OnShow (Sender: string; Action: string);
begin
Settings.location.Text := sLocation;
Settings.Button19.Click; //populate Trucking Companies grid with only users location
end;
on the settings form there is as table grid that shows the trucking companies - the table grid settings show all the companies no matter who is logged in or thier "location" so on the form I put a field text field and fill it from sLocation
Settings.location.Text := sLocation;
and then a button Settings.Button19.Click; that runs a sql query to fill the tablegrid with data filtered by the users locations that it gets from the text field.
SELECT TruckCompanies.id as "id",
TruckCompanies.Name as "Trucking Company",
locations.name as "Location"
FROM TruckCompanies
LEFT OUTER JOIN locations ON TruckCompanies.id_locations=locations.id
WHERE locations.name LIKE '%{location}%';
this seems like a poor work around your example seems a lot better - I just don't know where to fit it in.
actually I just added the second location in my data and realized pretty much every tablegrid and every dropdown
will need filtering by the location and the mess I made above isn't going to work.
the requirements are that users form seperate locations shuld not see each others entries, but seperate users from the same location should be able to see each others entries.
and finally an admin should be able to see and extract the data from all locations to be able to run cost reports.
here is my project - it works pretty well for one location as it was originally written - I've started adding the code and ability to have more than one location but with these filtering issues I am in over my depth.