-
grids
:wave:Hello Fellow VBites :wave:
Here I am with another question...what is the meaning of life??...oops!! no thats for my philosophy class(only me and my cat attend that ),
I am having little luck in allocating a RecordSource value in a conditional code(hmm thats doesn't make sense!!)
Let me explain(if indeed you can bear it)
I place on my form
the following items
1)A Data1
2)A Data Grid
3)A ListBox
4)A Comman Button
:D
In Data 1 I then pointed my DataBase name at the mighty Biblio database,changing RecordSource to "authors" .
I then changed the GRIDS DataSource to Data1.
Everything went according to plan and the grid filled up with all of those familiar authors.(a delight indeed but not very useful)
So now I would like to venture a little further and allow the grid to fill up ONLY when certain conditions are met..
So I placed the following code into my CommandButton
If List1.Text = "1" Then data1.RecordSource = "authors"
I ensured that I had removed any value in the RecordSource prior to this(so no authors)
ALAS no response form Mr VEEBEE,not even a suggestion to debug...just silence and an empty grid on my command click:ehh:
I tried a few variations on the above(loosing the " " and variations thereof but to no avail)
I also tried a little SQL code and replaced "authors" with SELECT * ect BUT to no avail.
So here is my weary question fellow VBites,
Does a chap or lady have to manually include the direction of the Record Source or indeed is it possible for this lowly chap to find a way of doing it ON THE FLY..through code.:confused:
Or am I just barking mad:afrog:
Any suggestions will be most welcome in my little back room in my little backwater of Wales(UK)
Kind Regards
Tommy
:thumb:
-
Re: grids
When you set the Data Control's RecordSource property at runtime you then need to call it's Refresh method in order to rebuild the underlying Recordset.
-
Re: grids
Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)
Is there a reason you are using a dreaded Data Control?
For an explanation of why it is a bad idea, see the article Why is using bound controls a bad thing? from our Database Development FAQs/Tutorials (at the top of this forum)
That article contains a link to the recommended alternative (ADO code), which has an example that replicates the main features of the data control. There are many other articles in the "Classic VB - ADO" section of the FAQs thread (particularly "the further steps" article), which help you to extend it in many ways - like adding search functionality, working with other controls, etc.
If you use code to work with the database instead, in the command button you just need to clear the grid, and re-fill it based on the apt SQL statement.
In terms of the grid you should use, I would recommend either a ListView (the FAQs contain an example of filling it) or a FlexGrid (example in my signature).
-
Re: grids
Wow!!
2 super answers Brucevde got me up an running again with that simple bit of coding,and Si The Geek giving me absolutly tons of of food for thought and pointers about ADO technology
I thank you both
Kind Regards
Tommy