The easiest way to get started at understanding this is to start a new project.
Select VB from the menu and when the dialog comes up select Application wizard. At some point within this wizard it will ask you if you want it connected to a database. Navigate to a database (northwind.mdb) and it will ask you what kind of view you want. Select datasheet view. There are more steps than this and its been so long I don't remember all of the steps but the application that is developed for you with this wizard will get you started. Remember that not all of the functionality is contained within the code. You will find some of it in the properties of the controls.
I just completed the same task, in Access all you make is subform, in VB you have to build it from the recordset(rs) or link the rs to the datasource(ds) property.
Here's the ds example:
Set MSFlexGrid.Datasource = rs.YourRecordSet
Replace MSFlexGrid with your grid name. You might want to use MSFlexGrid instead of the standard DataGrid, more flexibility.
----------------------
Here's the rs example:
You set of the columns.
With MSFlexGrid
.Cols =3
.Col =1
.Colwidth(.Col) = 1400
.ColAlignment(.Col) = 2
.Text = "Colname" -> not sure about this
Dim nAdded as Long
Dim rcString as String
While Not rs.EOF
rcString = vbTab & rs("f1" & vbTab & rs("f2"...
.AddItem rcString
rs.MoveNext
nAdded=nAdded+1
Wend
If nAdded>0 Then -> Chk rows added before removing last
Dim iRows as Long
iRows = .Rows -> number rows in grid not records
.RemoveItem iRows-1 -> removes the blank row
End If
End With
I hope this helps, you made need to tweak it some but you get the gist of it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.