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

DataGrid and hair loss

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi!

I'm just about to go crazy over this one. I have a DataGrid bound to an Adodc1. I need to be able to let the user change values on the grid, but since the DataGrid won't work in unbound mode, I've determined that the best way to validate the new changes is to collect the information on a separate form and validate it from there. Once the data is validated and ready to commit to the grid/database, the validate form returns the new data and it should be as simple as setting either the Grid.Columns(Index).Text to the new value, or Recordset.Fields(Name).Value and call Grid.Rebind or Grid.Refresh. The problem is no matter what syntax I can think of, the cell in the grid always ends up an empty string. Here's an example of my code:
--------------------------------------
Private Sub grdBB_DblClick()
If grdBB.Col <> 2 Then Exit Sub

With frmChangeRackNum
.RackNumber = grdBB.Columns(2).Text
.Show vbModal, Me '.RackNumber gets changed by user
'.RackNumber will be &quot;&quot; if canceled
If .RackNumber <> &quot;&quot; Then
grdBB.Columns(2).Text = .RackNumber 'problem line here
End If
End With

Unload frmChangeRackNum

End Sub
--------------------------------------

The really frustrating thing is on the &quot;problem line&quot; above, the debugger shows .RackNumber is correct, but after it executes that line of code, grdBB.Columns(2).Text always equals &quot;&quot;, NOT the value I've assigned it! This defies everything I know about assignment statements, and I've tried every variation of syntax and tecnique I can think of. No error is thrown, just a new blank field in the database. Does anyone know if the DataGrid will behave like this if certain other conditions are met/not met? I've checked all the design time grid stuff, and the user has no problem interacting with the grid.

Thanks alot!

~Mike

Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
When close frmChangeRackNum, are you unloading that form or hiding that form? If you unload it, the RackNumber variable is lost, hence the blank string. This would not return an error, just a blank string.

Try

frmChangeRackNum.Hide

instead of

Unload frmChangeRackNum

Hope this helps,
Adam
 
Yes, the form is hidden (not unloaded) until after the value I need from it is used. To elaborate, here's the problem again:

grdBB.Columns(2).Text = .RackNumber

When the statement pointer has this line highlighted, grdBB.Columns(2).Text = &quot;105.01&quot; and
.RackNumber = &quot;101.01&quot;.

After the statement has executed,
grdBB.Columns(2).Text = &quot;&quot; and
.RackNumber = &quot;101.01&quot;

As you can see, .RackNumber still contains the value I want assigned to the cell, but the cell now contains an empty string instead.

Thanks for the reply, tho. Every idea I can get definately helps! I'm completely lost here...

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top