Thanks for all your help so far.

I'll look into the parent combobox - it might be part of the solution.

I'm getting there:


CalcShipping.truckCombo.dbSQLExecute('SELECT TruckCompanies.id, '+
            'TruckCompanies.Name, '+
            'locations.name '+
            'from TruckCompanies '+
            'LEFT OUTER JOIN locations ON TruckCompanies.id_locations = locations.id '+
            'WHERE (locations.name = ''' +sLocation+''')');

this is the sql I need - maybe I'm asking for too much data???

SELECT TruckCompanies.id, TruckCompanies.Name, locations.name
from TruckCompanies
LEFT OUTER JOIN locations ON TruckCompanies.id_locations = locations.id
WHERE locations.name = "Garden City";

at least this gets the correct list when run in SQLiteStudio

this is what I get when I try that code

SELECT id, "TruckCompanies"."Name" FROM "TruckCompanies" WHERE locations.name = "Garden City"

what I actually need on the calculator form
there is a place to choose the only the trucking company servicing this location
right now it shows trucking companies from all locations
also the products, the origins, and the destinations also all need to be filtered by the location they are tied to.

Maybe I am approaching this problem from the wrong direction?

I'd actually like to filter in more ways to make the form smarter, once the trucking company is chosen, I'd also like to refilter the output to the product/product type list so that only product the trucking company hauls are shown, and then again when the product has been chosen with only origins that this trucking company service and have this product, and then again only destinations that this trucking company delivers this product to.

and before I go that way I guess I need to check with the user if that logic makes sense.  It might be better to reorder to choose the product first, then filter by locations that can provide that product etc...

ps.. I already have

 1=1 Order By Name asc

in the filter line on the form item so it sorts alphabetical.

the .dbupdate line errors on my version 3.2  is that a new feature?

That worked great Thanks!

the next step is to limit the comboboxes on the Calculator form

I found that there is an option to fill them with sql.
so I am looking into how this will work

Form1.ComboBox1.dbSQLExecute ('SELECT fieldname, id FROM tablename');

thanks for the explanation, I see where it is doing that now.

Sorry - I thought I had attached my project

I've looked at your sample and Im not sure yet how you made it work that way.

9

(1 replies, posted in FAQ)

Thank you!

10

(17 replies, posted in General)

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. smile

Thanks!  I checked it out - seems to do what I need.

12

(17 replies, posted in General)

I have a table on my database that has the users location,  the name of the town where the office is located.  The variable is set based on the login name.



I tried putting a empty text field named 'location' on the form and filling it with the variable sLocation and then using '%{location}%'  which works when you fill the table grid with sql - but there must be another method when it is used via the filter setting as it doesn't get replace by the value.

I set the user and location at the top of the script

var
   sUser: string = '';
   sLocation: string = '';

is there a way to limit the tablegrids for tables that have a related location column
based on the the location that was set when the user logged in?

I know I can fill them with custom sql queries but was wondering if I could use the filter on the table grid settings for this somehow.

something like

locations.name = sLocation

I want to be able to send the customer one file and not have to have them unzip and create a desktop icon.

I heard mention on here of using an installer.   What are you using?

15

(1 replies, posted in General)

I set up https://code.google.com/archive/p/ssh-tunnel-manager/ so I can make my database not accept external connections. 


I have tried this and it works (initally with only 2 connections) - but is there are way to start it when program loads
before the it tries to connect to the database?

Maybe not so much securing but tunneling out of corporate firewall.

16

(3 replies, posted in General)

I came across the "search in combo" topic and downloaded the beta version to try it

It is a better solution than what I came up with, Which was a combo hidden behind a text that with an onclick opened a sub form positioned above it that had a field and a table grid to simulate a searchable combo.

the only problem with using the beta is that the generated .exe causes a security warning.   But I can wait to roll out to producton until this is ready.  It will get rid of 4 of subforms I had already used.

17

(9 replies, posted in Script)

wow - thanks!

18

(3 replies, posted in General)

I have a form with a subform  that is called when I look up a customer.  It returns the customer info to the main form.

I want to do the same thing on another form which I could completely duplicate the form - but I got to thinking - is there a way to pass the form id to the sub form so that It  can be called  from any form that wants that method of selecting a customer.

19

(9 replies, posted in Script)

It has changed a bit but is working - I found out the price was by the product category so I had to add categories to the products and fill the category field by the product selected. but can I make this more efficient by running the SQL query only once to get both values?  If so does it come back as an array? I guess I need to study arrays

    flatrate := SQLExecute('SELECT FlatRate FROM FreightRateChart '+
        'LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id '+
        'LEFT OUTER JOIN ProductsType ON FreightRateChart.id_ProductsType = ProductsType.id '+
        'LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id '+
        'LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id '+
        'WHERE (TruckCompanies.Name = '''+CalcShipping.truckCombo.Text+''') '+
        'AND (ProductsType.Name='''+CalcShipping.prodtypecombo.Text+''') '+
        'AND (LoadOrigin.Name='''+CalcShipping.originCombo.Text+''') '+
        'AND (LoadDestination.Name='''+CalcShipping.destinationCombo.Text+''') '+
        'ORDER BY FreightRateChart.id DESC LIMIT 1;');
    surcharge := SQLExecute('SELECT Surcharge FROM FreightRateChart '+
        'LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id '+
        'LEFT OUTER JOIN ProductsType ON FreightRateChart.id_ProductsType = ProductsType.id '+
        'LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id '+
        'LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id '+
        'WHERE (TruckCompanies.Name = '''+CalcShipping.truckCombo.Text+''') '+
        'AND (ProductsType.Name='''+CalcShipping.prodtypecombo.Text+''') '+
        'AND (LoadOrigin.Name='''+CalcShipping.originCombo.Text+''') '+
        'AND (LoadDestination.Name='''+CalcShipping.destinationCombo.Text+''') '+
        'ORDER BY FreightRateChart.id DESC LIMIT 1;');

    CalcShipping.PriceTon.Text := flatrate;
    CalcShipping.SurchargePercent.Text := surcharge;

20

(9 replies, posted in Script)

Sorry -  I was away from project for a few days.  Thaks for your help!

21

(9 replies, posted in Script)

if  I run this in sqlitestudio I get the correct answer

SELECT FreightRateChart.FlatRate 
FROM FreightRateChart 
LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id 
LEFT OUTER JOIN Products ON FreightRateChart.id_Products = Products.id 
LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id 
LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id 

WHERE TruckCompanies.Name LIKE 'Trucking Co4'
  AND Products.Name LIKE 'Gas' 
  AND LoadOrigin.Name LIKE 'Origin1' 
  AND LoadDestination.Name LIKE 'Dest1'

ORDER BY FreightRateChart.id DESC LIMIT 1;

but when I try in mvd with

flatrate := SQLExecute('SELECT FlatRate FROM FreightRateChart LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id LEFT OUTER JOIN Products ON FreightRateChart.id_Products = Products.id LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id WHERE TruckCompanies.Name ''' +Form1.truckCombo.Text+ ''' AND Products.Name ''' +Form1.productCombo.Text+ ''' AND LoadOrigin.Name ''' +Form1.originCombo.Text+ ''' AND LoadDestination.Name ''' +Form1.destinationCombo.Text+ ''' ORDER BY FreightRateChart.id DESC LIMIT 1; ');

flatrate never gets set to a value

I don't think I am understanding the method of getting the variables into the sqlquery properly.

22

(9 replies, posted in Script)

I had figured out the limit 1, 
I am struggling with how to take that long sql and wrap it into a SQLExecute with the 4 variables needed to get the two results.

Also can I get them both with one call to the database or do I need to run it twice.

here is the project the freight table shows the sql working to filter the list for editing etc.

23

(9 replies, posted in Script)

this sql query wroks to fill and filter a table grid  - now in a form I need to
choose Truck company, Products, Origin and Destination  and then get the Flat rate and Surcharge  from the database - if there are multiple that match I just need the newest one.

SELECT FreightRateChart.id,
       TruckCompanies.Name,
       Products.Name,
       LoadOrigin.Name,
       LoadDestination.Name,
       FreightRateChart.FlatRate,
       FreightRateChart.Surcharge,
       strftime ( '%m/%d/%Y',FreightRateChart.Updated)
From FreightRateChart

LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id
LEFT OUTER JOIN Products ON FreightRateChart.id_Products = Products.id
LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id
LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id

WHERE TruckCompanies.Name LIKE '%{TruckSearch}%'
  AND Products.Name LIKE '%{ProdSearch}%'
  AND LoadOrigin.Name LIKE '%{OriginSearch}%'
  AND LoadDestination.Name LIKE '%{DestSearch}%'

ORDER BY FreightRateChart.id DESC;

I would like the ability to select multiple items to move at once. 
especially to drag a selectbox around multiple items and they all get selected.  then click and drag the whole group

but optionally to select items and group them so that next time I want to adjust the position I can move thw whole group.     On second thought I guess I could use panes for that part of it.

25

(2 replies, posted in General)

Thanks, I guess that wouldn't be too bad.

Has anyone here used a http tunnel proxy to connect to a mysql database?