Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting the focus on a cell in a datagrid
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00601919
Message ID:
00602457
Vues:
25
The lock type is 3-Optimistic.

Here is the code for editing a record in the grid
Private Sub grdTO_Detl_DblClick()
'Set columns equal to text and combo boxes
BtnsECMEditMode
'mECMEdit = True

Dim I As Integer
For I = 2 To 18 - 1
grdTO_Detl.Columns(I).Locked = False
With grdTO_Detl
.AllowDelete = True
.AllowUpdate = True
.Enabled = True
End With
Next

With grdTO_Detl
txtECM_Num = .Columns(2).Text
cboECM_Type = .Columns(3).Text
txtTotProjCst = .Columns(4).Text
txtFirstYrGuar = .Columns(5).Text
cboM_V = .Columns(6).Text
txtSavKW = .Columns(7).Text
txtSavKWH = .Columns(8).Text
txtSavDTH = .Columns(9).Text
cboFuelType = .Columns(10).Text
txtKWSavAmt = .Columns(11).Text
txtKWHSavAmt = .Columns(12).Text
txtDTHSavAmt = .Columns(13).Text
txtAncilSavAmt = .Columns(14).Text
txtContrPaymnt = .Columns(15).Text
txtPayDate = .Columns(16).Text
cboBuilding = .Columns(17).Text
txtTerm = .Columns(18).Text
DetailFieldsEnable
End With
txtECM_Num.SetFocus

End Sub

To save the edit (or the add) here is the code:
Private Sub cmdSaveDetail()

With grdTO_Detl
.AllowAddNew
.AllowUpdate
.Columns(2) = txtECM_Num.Text
.Columns(3) = cboECM_Type.Text
.Columns(4) = txtTotProjCst.Text
.Columns(5) = txtFirstYrGuar.Text
.Columns(6) = cboM_V.Text
.Columns(7) = txtSavKW.Text
.Columns(8) = txtSavKWH.Text
.Columns(9) = txtSavDTH.Text
.Columns(10) = cboFuelType.Text
.Columns(11) = txtKWSavAmt.Text
.Columns(12) = txtKWHSavAmt.Text
.Columns(13) = txtDTHSavAmt.Text
.Columns(14) = txtAncilSavAmt.Text
.Columns(15) = txtContrPaymnt.Text
.Columns(16) = txtPayDate.Text
.Columns(17) = cboBuilding.Text
.Columns(18) = txtTerm.Text
End With
DetailFieldsDisable
End Sub

Here's the add a record code:

Private Sub AddDetail()
mECMAdd = True
Dim I As Integer
For I = 0 To 18 - 1
grdTO_Detl.Columns(I).Locked = False
With grdTO_Detl
.AllowAddNew = True
.AllowUpdate = True
.Enabled = True
End With
Next
End Sub

The above code adds a blank line to the grid. The issue is that unless the user sets focus on a cell in the new blank line in the grid and enters at least one character and then goes to the text boxes, the record is not added. Could it be that the field I have as the identity field does not get written to the rs until data are entered in the grid itself?

I appreciate the response.


>If I well understood, You have problems with saving a record that was added to the recordset using code(with AddNew).
>What is the value of the property LockType of your recordset ?
>Can you show me the code used for adding&editing the new record? ..and the other one for saving ?
>You certainly not have to use arrays to do such things.
>
>Ciao,
>Ernest
CLARC Services, Inc.
3500 Tamiami Trail
Port Charlotte, FL 33952
www.clarc.com
(941) 743-0108
(800) 246-5488
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform