Hi,
I’m a bit stuck at the moment. Hope someone can help point me in the right direction.
I have a an SQL query along the lines:
SELECT AVG(Col1), AVG(Col2) FROM mytable
WHERE :Val1 IS NULL OR Col1 = :Val1
AND :Val2 IS NULL OR Col2 = :Val2
I have a separate tables in calc display the results:
AVG Col1, AVG Col2
42%, 99%
And an input table to filter to be used as input:
Col1, Col2
Val1, Val2
My query is working fine when run it manually
- I get a prompt to enter the parameter value
- I get results to a table form output
- I drag the results into some target cells
- If I refresh using Data > Refresh Range, I get the query parameter prompt and the output table updates as expected.
My goal is to have just input cells and trigger the lookup again and populate the target cells with a button (or cell selection event).
I’m not looking for any DB inserts/updates.
For the input to the query - I have tried using a macro on the form’s “Fill Parameters” event:
Sub ParamCheck(oEvent)
If oEvent.Parameters.Count = 0 Then
Exit Sub
End If
For i = 0 to oEvent.Parameters.Count -1
prop = oEvent.Parameters.getByIndex(i)
If prop.Name = "Val1" Then
prop.Value = "something"
End If
If prop.Name = "Val2" Then
prop.Value = "something_else"
End If
Next
End Sub
This works fine when I run it manually again - I do not get a prompt box asking to type in the parameter values, it just uses the ones set in the macro.
However, if I then trigger a refresh of the Database Range using the ‘Refresh Range’ I still get a prompt box - it seems to ignore the Form’s Fill Parameters event.
I have also tried to update using this solution MySQL DATE_ADD not recognized in datagrid
which uses
oDBRange.getReferredCells.doImport(oDesc())
But this also prompts for manual entry of the parameters.
I would be very grateful for any help on this.