PDA

View Full Version : Undo current record/delete



Trevor
03-27-2008, 12:28 PM
I have a form , that add info to table via inert query(nothing bound)
I also have a msgbox that will fire if condions arn't met,
my question is how do I undo the inert query just performed in an earlier event if the msgbox fires
Tables![Tablename].currentRecord.Undo is my guess, but I doubt it will work becase I don't think you can reffer to tables in that fashion
and because this is going to be on a Lan using movefirst and movelast I don't think will work since it may undo someone else record

ben.oates
04-01-2008, 02:36 AM
Why not use a recordset rather than an insert query and hold off on the .Update until you're sure you want the data in there?

asingh
04-01-2008, 03:30 AM
You cannot undo..table transactions. Best you could do..before the action query..back up all the data into a back up table. If you want to UNDO..pull it back from there...

Trevor
04-02-2008, 07:31 AM
thanks you 2 and ben.0ats I the reason why not using a recordset is simply didn't feel like it and now it would be harder to go back and link, and Now that I think about it I kind of like it this way.
Its a logon screen, if attempts reach a count of x your locked out for a time, but if you contine to try to login you only extend your lockedout time :-p

CreganTur
04-02-2008, 08:29 AM
Another options is to have the check for the condition that fires your message box occur before the update query is run. That way if the MsgBox is fired, then you can follow it up with an Exit Sub, which won't allow the Update to fire.


Dim sql

sql = [enter SQL code for query here]

IF variable = False
MsgBox "Data Incorrectly Entered" & vbCrlf & vbCrlf & "Update will not occur.
Exit Sub
ElseIf variable = True
Me.RecordSource = sql
Me.Requery


This might not be desireable, it all depends on the exact circumstances you're working with.

Trevor
04-02-2008, 10:04 AM
Cragentur , your right that would be my only option in this case, did you check out my last post, thank for the reply.

FrymanTCU
04-04-2008, 09:59 AM
It's not completely off topic but a different direction and it may have been discussed before so don't hate on me just attach the link. If this hasn't been covered before I think it could an interesting debate!

So what are the advantanges or differences between the SQL insert and update query method versus the Dim.Recordset method? I have used both and I feel the SQL is shorter and easier to write but I may be missing something so I felt I should ask.

CreganTur
04-04-2008, 12:21 PM
It's not completely off topic but a different direction and it may have been discussed before so don't hate on me just attach the link. If this hasn't been covered before I think it could an interesting debate!

So what are the advantanges or differences between the SQL insert and update query method versus the Dim.Recordset method? I have used both and I feel the SQL is shorter and easier to write but I may be missing something so I felt I should ask.

Personally I feel like I have more control using the SQL code, because all of my queries are in SQL, so I understand it- which is probably the reason why I use it. I don't know anything about using the Dim.Recordset method.

Trevor
04-04-2008, 08:03 PM
FryManTCU, they all achieve the same end result
different strokes for different folks, the dim recordset seems like its a few lines of code because you have to declare the rst, then loop through it or getrow() then insert, The SQL seems to be much faster to wright and easyer to follow if you have to debug