Cancel Database Update on a Bound Form

  • Thread starter Thread starter BBM
  • Start date Start date
B

BBM

Is there a way to cancel the database update associated
with changing the value of a control on a bound form (a
textbox say), but still have the control act as if the
database update had occurred? That is, the cursor should
move to the next control on the form (possibly to the next
record), and the changed control should show the changed
value.

Thanks.

BBM
 
It is a bit confusing on what you are asking (unless I haven't had enough
coffee this morning).

If you want to cancel the ENTIRE changes, you can use: Me.Dirty=False (if
you have a SAVE button, you can put the code here).

On the Form's Before_Update() event, there is a CANCEL parameter. Set this
value to TRUE to cancel the ENTIRE changes.

Does this help?

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
I think he has a bound control, & he edits the value & presses Enter. He
wants the edited value to be retained in the control on the screen, & the
cursor move to the next control, but somehow, by magic, the underlying bound
field value >is not< updated.

IMO that doesn't seem wise from a UI viewpoint. How can a user possibly be
confident what is going on, when >some< edits are saved, but others are
invisibly ignored behind the scenes?

Cheers,
TC
 
My bound control contains a "keyword" that I want to use
in some other search panels. There is a many to many
relationship between keywords and the items they
describe. I want the user to be able to both create a new
keyword or just reference an existing keyword with the
same input.

So the user enters a keyword for an item and hits <Enter>
or <Tab>. The system should check to see if the keyword
already exists in the keyword table. If not, it updates
the keyword table and puts an entry into the cross
reference table tying the keyword to the item it
describes. My form (subform actually) is bound to a join
query of keywords to items so this function works OK.

If the keyword is found, however, then only the cross
reference needs to be updated. So I cancel the form based
update (using the cancel parm in the BeforeUpdate event of
the bound control) and explicitly update the cross
reference file only.

Now the problem is that because the update didn't occur
the cursor is still on the same input field, and each time
I try to leave it, it tries to re-update the database.

I'm hoping there's a simple way to tell the system to just
go to the next record as if the update had occurred. My
alternative is to create a temporary table just for the
keyword display, and populate it each time the subform is
referenced. I'll let whatever the user inputs be stored
in the temp table, and then figure out what "real" table
updates to make.

Thanks for your help.

BBM
 
I understand. Maybe a better approach would be to make the keyword textbox
unbound? Then, the Before and After Update events of that textbox, can
respond to entries by updating the database "manually", in whatever ways may
be required.

HTH,
TC
 
Hi, BBM

From your descriptions, I understood that you would like to keep the field
what it used to be when you find new inserted one is a duplicated PK in
another table, which is in many to many relationship with this table. Have
I understood you? If there is anything I misunderstood, please feel free to
let me know :)

Based on my knowledge, you should make an BeforeUpdate or AfterUpdate event
procedure and then send ESC keys. You could find that the change of one
Form field could be rollback by pushing ESC keys. That's what we just used.
You could make the codes like this:
'VBE coding
Private Sub Title_BeforeUpdate(Cancel As Integer)
MsgBox "Sorry, Wrong"
SendKeys "{ESC}"
End Sub
'End of codes

Hope this helps and if you have any questions or concerns, please feel free
to let me know :) We are here to be of assistance!

Sincerely yours,

Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
 
TC

That's pretty much what I've decided to try. Because the keyword is on a continuous sub-form I'll use a temporary file for the datasource and bind that to my field

Thanks for your help.
 
Michael

No, I'm actually trying to keep the input for the field, but NOT let Access do the update of the bound record

Still, from the other discussion on this topic. You can consider this closed.
 
Hello BBM,

I was reviewing this issue. Did you resolve the problem based on TC's suggestion? If there is any question on it, please feel
free to post here and we will follow up.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top