|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Recordset.update Pls help very urgent.
Hi all,
I need to update a record in the table. I'll list U what all the steps I have done. 1. Get the Primary field value 2. Based on the Primary field showed all the values in a form using recordset. 3. After the User Press the save button move the form values to the recordset 4. recordset.update But it updates the record & also creates a record with the updated values. Attached is the code. Pls help very urgent Private Sub editbtn_Click() On Error GoTo Err_editbtn_Click Set db = CurrentDb() Set tbl = db.OpenRecordset("select count(*) from offender where nric = '" & nrictemp & "'") nriccount = tbl(0) tbl.Close If (nriccount > 0) Then Set tbl = db.OpenRecordset("select max([date recorded]) from offender where nric = '" & nrictemp & "'") maxdate = tbl(0) tbl.Close Set tbl = db.OpenRecordset("select * from offender where nric = '" & nrictemp & "' and [date recorded]= #" & Format$(maxdate, "mm/dd/yyyy hh:nn:ss AM/PM") & "#") Call form_enable Assign the form fields with the recordset values Else MsgBox "No Records in FG Database for the entered IC", vbOKOnly, "EDIT WINDOW" Me.icfld = nrictemp Me.icfld.SetFocus End If Exit_editbtn_Click: Exit Sub Err_editbtn_Click: MsgBox Err.Description Resume Exit_editbtn_Click End Sub Private Sub Savebtn_Click() Dim savelogic As Integer On Error GoTo Err_Savebutton_Click If opt = 2 Then MsgBox "I am here 3 ", 0, 0 savelogic = 1 do validation checks If Validation is ok savelogic = 0 end if; If savelogic = 0 Then tbl.Edit recordset(0).. recordset(15)= form values MsgBox " I am here 5 ", 0, 0 tbl.Update tbl.Close DoCmd.Close acForm, "offndrfrm", acSaveNo DoCmd.OpenForm "offndrfrm", acNormal MsgBox " I am here 6", 0, 0 Else DoCmd.CancelEvent MsgBox " Pls Key in All Mandatory Fields ", 0, "Save Window" End If End If Exit_Savebutton_Click: Exit Sub Err_Savebutton_Click: MsgBox Err.Description Resume Exit_Savebutton_Click End Sub Thanks & Regards Raj But it Updates the Record & creates a New record with the updated values But it Updates the record & also creates a record with updated values |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Recordset.update Pls help very urgent. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|