Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2003, 02:16 AM
rajkumar rajkumar is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Singapore
Posts: 6 rajkumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Recordset.update Pls help very urgent.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT