|
-
Aug 1st, 2000, 09:29 AM
#1
Thread Starter
Evil Genius
Hi everyone, quick question...
I am not that new to VB, but have not used the datagrid or flexigrid controls before. on a form...load event, I want to populate 2 columns of one of these with data from an access 97 database using dao.
Just wondered if any of you knew / had seen any sites explaining / have examples of how these (flexigrid / datagrid controls) actually work as I am having trouble understanding them.
Many thanks everyone!
Alex Read
-
Aug 1st, 2000, 11:35 AM
#2
Hyperactive Member
I dont know of a site, but they are easy once you know how
did you want to bind the grid to a datasource or fill it in maually??
-
Aug 2nd, 2000, 02:31 AM
#3
Thread Starter
Evil Genius
thankx 4 replying
yes I need to populate one of these grids with all the data from the first 2 columns of my access 97 database (not sorted etc but the whole columns).
I realise this may be quite a bit of code, which is why I didn't ask for an example, but if you could shed a little light to start me off I would be most grateful.
Thank you
Alex Read
-
Aug 2nd, 2000, 02:34 AM
#4
Thread Starter
Evil Genius
actual reply after understanding the question, I do not mind, whatever is the easiest but I don't think I can bind it as the database is passworded and I have tried numerous ways to try and do this without sucess.
Thank you
-
Aug 2nd, 2000, 03:24 AM
#5
Hyperactive Member
easy way of not binding it...
OK, I've never used a datagrid control, but with a flexgrid control, you could use a SELECT statement to get the data you wnt from the db, then try this: -
Dim Newline as String
Newline = vbTab & rs!Col1 & vbtab & rs!Col2
fg.Additem Newline
Obviously, fg is the name of my flexgrid, and you would substitute rs.Col1 and rs!Col2 with the proper name for your datasources
the first vbTab is in there to make sure the Grey column on the left does not get filled in. If you want to use this column, then just remove it
hope this is of some help
-
Aug 2nd, 2000, 05:40 AM
#6
Thread Starter
Evil Genius
This is brilliant !
I would like to thank you for taking the time to answer that. I can now get this to work.
Previous examples & sample code told me I needed to put a text box on the page, copy the recordset data into the textbox, and then paste this over to the flexgrid cell for some reason, that was what was confusing me.
One last question if I can ask you again, with your example, this shows the first entry from the access daabase in my flexigrid table. I placed the following code in :
Dim Newline As String
Newline = vbTab & Rs!column1
fg.AddItem Newline
Rs.MoveNext
Do While Not Rs.EOF
Loop
In theory, if I am correct, this should loop through all the entries in that column & put each one into my flexigrid.
In practice, it takes a good few minutes & crashes the program (there are only 50 entries in the table). Is my code wrong? or do you have another way of doing this?
Thank you!
Alex Read
-
Aug 2nd, 2000, 06:22 AM
#7
Thread Starter
Evil Genius
Stupid question
Realise I didn't put the procedure within the do...loop statement, please ignore the last one and thanks for all your help!
-
Aug 2nd, 2000, 06:23 AM
#8
Hyperactive Member
if you want to loop thru it, i would do it something like this: -
do while not rs.eof
Newline = vbTab & Rs!column1
fg.AddItem Newline
Rs.MoveNext
newline = ""
Loop
I think what might have happened is that the program was adding the new column onto the end of the newline variableeach time. ths would in effect try to create the next line with more and more columns, which could, i suppose , cause the program to crash. ading the newline = "" will hopefully sort things out for you.
you might want to bear in mind that doing it this way will hold up your program, so if you ever want to have thousands of rows in your recordset your program will slow down. if this ever happens, I would suggest looking into bound controls again
Regards,
Jim
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|