I have combo box. How I can show the number of row in the data grid base on the number of record selected on combo box?
Printable View
I have combo box. How I can show the number of row in the data grid base on the number of record selected on combo box?
Does this Combo box hold the Record Number or any Value from the DB itself.
If its the Record Number, try like Rs.Move(recNumber).
If its a DB Value, then try like Rs.Filter = "MyDBField = " & MyComboVal
Note : Use of Filter was adviced to be eliminated in the Forum . I cant remember the exact case. So use wuth caution. And it needs the recordset to be loaded with correct records first.
:wave:
Filter is fine to use on smaller recordsets. For anything large you would want to modify the query to limit returned results.
@ RobDog888Quote:
Originally Posted by RobDog888
Just for my information, what do you consider to be a smaller recordset?
I just use this
Combo1.AddItem "1"
Combo1.AddItem "2"
Combo1.AddItem "3"
Combo1.AddItem "4"
Sorry guy. I use MSFlexGrid1
@aikidokid, I would say it would also depend on system resources and location of the db. But probably anything in the 10's of thousands of records and up.
You can use a loop to add the items with less code.Quote:
Originally Posted by matrik02
Code:Dim i As Integer
For i = 1 To 100
Combo1.AddItem i
Next
Sorry to hyjack this thread matrik02 :eek2:Quote:
Originally Posted by RobDog888
So with a DB like mine with only 100's or records, and on the same hard drive, this wouldn't be a concern.
No, should be quick and fine. ;)
Some mid to large size apps use massive databases with sizes up in the Gig range.
Thank you.
Code:Dim i As Integer
For i = 1 To 100
Combo1.AddItem i
Next
After that, I want to change the row number in the MSFlexGrid1, when I chose the row number in the combo box during run time.How to do that?
Use the Row and TopRow properties.
Code:Private Sub Form_Load()
Dim i As Long
MSFlexGrid1.Rows = MSFlexGrid1.FixedRows
For i = 1 To 100
MSFlexGrid1.AddItem i
Combo1.AddItem i
Next i
End Sub
Private Sub Combo1_Click()
MSFlexGrid1.Row = Combo1.Text 'Set current row
MSFlexGrid1.TopRow = MSFlexGrid1.Row 'makes sure row is visible
End Sub
Actually I would like to set the row number..
If I choose number two in the combo1..MSFlexGrid1 with have 2 row.
If I choose number seven in the combo1..MSFlexGrid1 with have seven row
and so on..
How to do that?
You mean you want to set the number of rows in the grid.Quote:
Actually I would like to set the row number..
MSFlexgrid1.Rows = CLng(Combo1.Text) + MSFlexGrid1.FixedRows