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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dbgrid

Status
Not open for further replies.

samantha72

Programmer
Jul 31, 2001
14
0
0
CA
I populated a dbgrid via a stored procedure.
my grid looks like this
name type desc
aaa 0 ddddddddd
bbb 1 eeeeeee

i want to loop through this grid and replace the type column if 0 then
form and if 1 then Memo

I am unable to do this as i keep getting errors such as column.text is read only

this is how i am trying to loop
With cmdKits
.ActiveConnection = mcnnDB
.CommandText = "DisplayKits_Forms_pr"
.CommandType = adCmdStoredProc
.Parameters.Append cmdKits.CreateParameter("Language", adTinyInt, adParamInput, 1, giLang)
End With

rskits.CursorLocation = adUseClient
rskits.Open cmdKits, , adOpenKeyset, adLockReadOnly

Set frmOrder.dbgKits.DataSource = rskits

call kitorform
this is how i populate the grid

'This procedure loops through the grid and replaces the
'1 or 0 with the work Form or Kit
Private Sub DisplayKitorForm()

Dim iRowIdx As Integer


For iRowIdx = 0 To dbgKits.ApproxCount - 1 Step 1
' 'show form in the cell
If dbgKits.Columns(1).Text = 1 Then
dbgKits.Columns(1) = "Form"
Else
'show memo in the cell
dbgKits.Columns(1).Text = "Memo"
End If
Next

please help me out . Thanks
 
If you are using the Microsoft Databound Grid, right click the grid, select Properties, Click the Columns tab, pick the column you wish to change, and set the NumberFormat property to:

"Form";"Memo"

This assumes you have linked the grid to a recordset at design time, and have already selected "Retrieve Fields"

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top