Cancel Cllick Event Won't Cancel

M

Mike Boozer

My AddRecord control does a lot when clicked. It makes a number of other
controls Enabled=-False until the new record is entered. What if the user
clicks AddRecord and then changes his or her mind? A number of controls have
now been disabled with the AddRecord on_click event. Escape does not work.
Neither does DoCmd.CancelEvent or Me.AddRecord.Cancel=True.

I tried simply DoCmd.Requery for the cancel button but this cycles through
all the records and screws up my custom Leban navigation record button
record counts. My best fix so far is simply on click, go to previous record.
This re-enables all of the disabled controls. Only problem is that clicking
the cancel button again goes to another previous record and so on. Any help
is muuucho appreciated. Thanks.
 
M

Mike Boozer

I also tried
If Me.NewRecord And Not IsNumeric(Me.[IDPartNo]) Then
Cancel = True
MsgBox "Cancelled Add Record."
End If
This just leaves me with a blank record. I want to go back to the previous
record just "one time" only.
 
B

Brandon

Mike

Set the tag property of the controls that you want to switch from on to off to something identifiable like "Switch"
You can then scroll through the controls by doing something like this when the user cancels the orde

dim c as contro
for each c in me.control
if c.tag="switch" the
c.enabled=tru
end i
next
This will scroll through the control collection and re-enable the controls.

**** Please note that this should work for all controls. If you use this example to unlock or lock controls or change other functions you may have to test for the type of control

You may have to add the following code
if c.controltype = acTextbox the
add code her
end if
 
M

Mike Boozer

Thanks Brandon.Appreciate the code. I'll code it tonight. Thanks again.


Brandon said:
Mike,

Set the tag property of the controls that you want to switch from on to
off to something identifiable like "Switch".
You can then scroll through the controls by doing something like this when the user cancels the order

dim c as control
for each c in me.controls
if c.tag="switch" then
c.enabled=true
end if
next c
This will scroll through the control collection and re-enable the controls.

**** Please note that this should work for all controls. If you use this
example to unlock or lock controls or change other functions you may have to
test for the type of control.
 
M

Mike Boozer

Brandon. Tag code works great except in addition to reenabling controls, I
want to mimic the keyboard "escape"button but not sure how to code in vb if
it can be coded. I'll search newsgroup for possible answer.


Mike Boozer said:
Thanks Brandon.Appreciate the code. I'll code it tonight. Thanks again.


Brandon said:
Mike,

Set the tag property of the controls that you want to switch from on to
off to something identifiable like "Switch".
You can then scroll through the controls by doing something like this
when
the user cancels the order
dim c as control
for each c in me.controls
if c.tag="switch" then
c.enabled=true
end if
next c
This will scroll through the control collection and re-enable the controls.

**** Please note that this should work for all controls. If you use this
example to unlock or lock controls or change other functions you may have to
test for the type of control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top