FastReport4 CheckListBox1 C++
Hello everyone [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
I need help with Fast Report 4.8
I placed CheckListBox1 on the Dialog page, im using query Defdok:
SELECT d.*
FROM
dbo.DefDok d Order by Nazwa
Query shows me:
Fvat
PZ
WZ
etc....
I need to place that data from query DefDok to CheckListBox1.
When data from DefDok will be i need to choose what i want 2 use in another query..
So when i will choose from CheckBOxList1 Fvat or PZ or both and i press button ok it will show me report only with this 2 things: Fvat and PZ.
Greetings[/img]
Comments
Try to make another step - you can test it with FR 4 compiled demo.
My idea is to get records chosen by end user in a dialog (in your case DefDok - types of warehouse docs ?) and make use of them in another query (with a specific where clause) to minimalize traffic from database and print all MasterData bands.
I used ADOQuery1 like
And yet a few lines of FR script. First to fill Items:
And finally to read what was chosen in a dialog
Here you can do whatever with MyStates string, I mean you can use it for filtering the database tables.
Mick
So it will need 2 looks something like:
CheckListbox
Dok1 2011.5.1
Dok2 2011.4.1
etc
Earlier it was: (CheckListBox)
Dok1
Dok2
After all i need 2 use only my 'state' or 'data' to filtering the database tables.
select custno, company
from customer
where custno < 3000
order by custno
and more FR script
And finally you may now add the above string to your another query to change where clause according to your database syntax. Pay attention that you have got A STRING of concatenated PURE string values and yet separated by comma. Usually such strings are not acceptable by database engines when used within ... in (...) search conditions.
Here (in this forum) you can find examples of how to build dynamic where clause in a query. Both Gorousek and me gave some of them. So search the forum and try to convert those examples to satisfy your needs [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick[/img]
SELECT d.*
FROM
dbo.DokHan d
Where Data >= (:Data1) and Data <=(:Data2) AND Typ IN (:TypDok)
but when i choose on CheckListBox1 more than 1 data iv got error:
Conversation failed when converting the varchar value '100|101|200' to data type int.
WItch choosing only 1 option it works perfectly [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> With friend help iv deleted from query "AND Typ IN (:TypDok)" and he added something like that 2 code: TypDok := Copy(TypDok, 2, Length( TypDok)-1); DokHanPoz.SQL.Text := DokHanPoz.SQL.Text + ' AND Typ IN (' + TypDok + ')'; <<<<<ADDED ShowMessage ( TypDok); Now i'm testing it but right now it's working very well[/img]
you may get a better string for where clause using code like below
and you get a string like: <'1123', '1189', '1199', '2001'>
what finally let you use your code:
DokHanPoz.SQL.Text := DokHanPoz.SQL.Text + ' AND Typ IN (' + TypDok + ')'; => that's a smart dynamic SQL creation [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Take care: in general two strings <'PZ,RW,FAK,MM'> and <'PZ','RW','FAK','MM'> are two different strings for database engine. Syntax of[/img]IN search condition is similar to where a.colname IN ('item1', 'item2', 'item3')
and if you write where a.colname IN ('item1,item2,item3')
then your where clause may fail if A.Colname will hold a string 'm1,it'.
If your Query (DokHanPoz.SQL) has an order by clause then you cannot use construction as the above.
Order by clause must be the last one within a select statement. So in such a case you must change your code a little bit [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick[/img]
2. Are radiobuttons used to fill CheckListBox according to the meaning of these radiobuttons ?
3. What should be done if user cliks on one radiobutton, and then he cliks on another?
Mick
2) Yes it need 2 clear list on CheckListBox and fill with few data not all datas like on point 1)
3) If I hit another radiobutton it will do the same if do point 2 but it will fill with another datas
I will try to whow what i want 2 do.
If the FR4 stars dialog fills the same data it war earlir on CheckListBox1
ok and cancel buttons do the same
If i will click on RadioButton1 or RadioButton2 etc it will clear items from CheckListBox, it will fill with new 3-5 datas with marked square.
Clickin on ok it will count this new datas on CheckListBox and do the same at it was earlier.
1. Set CheckListBox1.Enabled := false and make it empty when dialog starts
2. Use OnClick event for each radiobutton, and within that event fill CheckListBox1 with ONLY proper data user should see
3. Set CheckListBox1.Enabled := true, SetFocus to CheckListBox1
4. After clik at any radiobutton its event should refill CheckListBox1 with NEW proper data
I hope this is what you are looking for [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick[/img]