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 "" if canceled
If .RackNumber <> "" Then
grdBB.Columns(2).Text = .RackNumber 'problem line here
End If
End With
Unload frmChangeRackNum
End Sub
--------------------------------------
The really frustrating thing is on the "problem line" above, the debugger shows .RackNumber is correct, but after it executes that line of code, grdBB.Columns(2).Text always equals "", 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
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 "" if canceled
If .RackNumber <> "" Then
grdBB.Columns(2).Text = .RackNumber 'problem line here
End If
End With
Unload frmChangeRackNum
End Sub
--------------------------------------
The really frustrating thing is on the "problem line" above, the debugger shows .RackNumber is correct, but after it executes that line of code, grdBB.Columns(2).Text always equals "", 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