JHAKAS
11-09-2004, 01:40 AM
Hello to everybody
Wel say my table is having n number of records, now i want to update 5th reord, which is displayed on my form
Well then i click the update button for updating the record. Following code behind the screen
Code:
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset
If (ValidateData) Then
rs.Open "EMD_Master", GeoCon, adOpenDynamic, adLockOptimistic
With rs
If Add = True Then
.AddNew
.Fields(1) = txtEMDRefNo.Text
.Fields(2) = cmbTenderRef.Text
.Fields(3) = GetBankRefNo
.Fields(4) = Val(txtamt.Text)
.Update
MsgBox "Record Added Successfully"
End If
If Edit = True Then
.Fields(1) = cmbEmdRefNo.Text
.Fields(2) = cmbTenderRef.Text
.Fields(3) = GetBankRefNo
.Fields(4) = Val(txtamt.Text)
.Update
MsgBox "Record Updated Successfully"
End If
End With
End If
End Sub
Well addition is going on fine but the updation just changes the first record in the query.
What has to be done.
Shall i make a query to select the particluar record, which i want to update and then rest update portion as in Edit one given above
Sandeep
Wel say my table is having n number of records, now i want to update 5th reord, which is displayed on my form
Well then i click the update button for updating the record. Following code behind the screen
Code:
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset
If (ValidateData) Then
rs.Open "EMD_Master", GeoCon, adOpenDynamic, adLockOptimistic
With rs
If Add = True Then
.AddNew
.Fields(1) = txtEMDRefNo.Text
.Fields(2) = cmbTenderRef.Text
.Fields(3) = GetBankRefNo
.Fields(4) = Val(txtamt.Text)
.Update
MsgBox "Record Added Successfully"
End If
If Edit = True Then
.Fields(1) = cmbEmdRefNo.Text
.Fields(2) = cmbTenderRef.Text
.Fields(3) = GetBankRefNo
.Fields(4) = Val(txtamt.Text)
.Update
MsgBox "Record Updated Successfully"
End If
End With
End If
End Sub
Well addition is going on fine but the updation just changes the first record in the query.
What has to be done.
Shall i make a query to select the particluar record, which i want to update and then rest update portion as in Edit one given above
Sandeep