Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get info from a database to a MSHFlexGrid

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
Does anyone know how to get data from a database to a MSHFlexGrid. I know the ".AddItem" method and "vbTab", but I need to know how to get the record I need from the database(specific record). I don't know how to get the click event to point to the right row. Anyone?? Every day above ground is a GOOD DAY!!!
 
A trick I have used in the past is to hide a textbox that moves with the grid and user selection. This way you can utilize the value of the text field and its events and then populate something else depending on the grid selection. Does this help or give you ideas?

Joanne
 
Yea, I've actually downloaded that as a tutorial from a web site somewhere, can't remember which one. I figured it out with an SQL statement though. I didn't want the datagrid to be editable though, just transfer a row of data from a recordset. Kind of like an invoice. I did it like this:

sql = "Select * from Table Where Item = 'ItemWanted'"
Call AddNewItem

Private Sub AddNewItem_Click()
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
If rs.EOF = True And rs.BOF = True Then
rs.MoveFirst
End If
Row = rs.Fields("Item#").Value & vbTab & rs.Fields ("ItemName").Value & vbTab & rs.Fields("Quantity").Value & vbTab & rs.Fields("ItemPrice")
frmFlexGrid.flexGrid1.AddItem Row
rs.Close

There are so many items in the database though, I made the AddNewItem as a sub so I can call it and add the information to the datagrid. If there is an easier way to do it, anyone please let me know as the database is rather large.
Now all I have to do is figure the formula to get a total of the ItemPrice column on the flexgrid.

Thanks for your time Joanne. I appreciate it.
Every day above ground is a GOOD DAY!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top