|
-
Apr 10th, 2004, 11:47 PM
#1
Thread Starter
Lively Member
UPDATE record as last record in recordset... Updating a recordset generally?
As the title of the message suggests, I have an UPDATE statement which Updates a record in a table.
Firstly the AddNew adds a new record, and reserves it a space by Inserting the Primary Key into a new record the table (In this way the recordspace is reserved and that primary key preserved). If the user should cancel, that record is deleted. Both are working fine...
If the user does not cancel, but instead presses Update, the remaining fields are Updated into that appropriate record in the table, this is also fine...
The problem then arises, after adding 1 record...
If the user either tries to browse back or forwards, it will not move at all.
so the only way to even (half) get around this is...
If the user then clicks AddNew again, and then Cancel again,
they can now browse through records again, but the previous record that was inserted appears to have gone missing...
But, oh no it hasnt, it has inserted itself at the beginning of the recordset
Why?
Because of this, it either makes me believe...
(a) the Recordset adoPrimaryRS is not being updated properly
or
(b) there is a problem with the AddNew button (although I could be wrong)
After using the INSERT INTO, I have tried each of the following:
.Requery
.Resync
.Update
.Save
None have worked, they keep complaining about creating duplicate records
The code for my cmdUpdate button is as follows:
Code:
cmdUpdate_Click()
Dim InsertTaskRecord As String
InsertTaskRecord = "UPDATE Task SET TaskName='" & txtTaskName & "', TaskPriority='" & txtTaskPriority & "', TaskDate='" & txtTaskName & "' WHERE Task.TaskID='" & txtTaskID & "'"
db.Execute InsertAdminRecord
End Sub
and the code for my AddNew button is as follows:
Code:
cmdAddNew_Click()
Dim InsertNewTask
InsertNewTask = "INSERT INTO Task(TaskID) VALUES('" & txtTaskID & "')"
db.Execute InsertNewTask
Can anyone see the solution to this problem or what could be wrong with what I have done ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|