Solved

ActiveControl.Undo Not Working

Posted on 2001-08-16
8
415 Views
Last Modified: 2012-08-13
Here's the code:

Private Sub cboDesignAssociateID_Change()
    If Screen.ActiveControl.Column(2) = True Then
        MsgBox "Selection """ & Screen.ActiveControl.Column(1) & """ is inactive, please choose another.", vbExclamation, AppName
        Screen.ActiveControl.Undo
        Screen.ActiveControl.Dropdown
    End If
End Sub

if the user selects an inactive selection, then i want a message to pop up saying that this selection is inactive and undo the combo box and drop it down.

the message and the dropdown part works buts its not undoing the control! if i use Sendkyes "{Esc}" instead, it undoes the whole record, not cool.  arrrgghh!!! i cant stand access's little quirks!!!  sorry.
0
Comment
Question by:davidsanderson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6393408
hi davidsanderson,

try this


Private Sub cboDesignAssociateID_Change()
   If Screen.ActiveControl.Column(2) = True Then
       MsgBox "Selection """ & Screen.ActiveControl.Column(1) & """ is inactive, please choose another.", _
vbExclamation
       Screen.ActiveControl.Undo
       Screen.ActiveControl = ""
       Screen.ActiveControl.Dropdown
   End If
End Sub
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6393413
oops, leave out the

Screen.ActiveControl.Undo


cheers
Ricky
0
 
LVL 57
ID: 6393463
<<the message and the dropdown part works buts its not undoing the control! if i use Sendkyes "{Esc}"
instead, it undoes the whole record, not cool.  arrrgghh!!! i cant stand access's little quirks!!!  
sorry. >>

  It's not a quirk, it's defined behaviour.  First time esc is pressed it undoes the current control, second time the record.  If the current controls is not dirty (can't be undone), then it does the record.

  Since your not being explicit, Access does what it's design to do.

  Also, I'd avoid the use of ActiveControl at all costs.  It's a pain to debug.

Jim.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 12

Accepted Solution

by:
Paurths earned 50 total points
ID: 6393490
so then it would look like :

Private Sub cboDesignAssociateID_Change()
   If cboDesignAssociateID.Column(2) = True Then
       MsgBox "Selection """ & cboDesignAssociateID.Column(1) & """ is inactive, please choose another.", _
vbExclamation
       cboDesignAssociateID = ""
       cboDesignAssociateID.Dropdown
   End If
End Sub


cheers
Ricky
0
 

Author Comment

by:davidsanderson
ID: 6394136
ok, thanks ricky, that lead me in the right direction.  i gave up on trying to undo it.

    If Screen.ActiveControl.Column(2) = True Then
        MsgBox "Selection """ & Screen.ActiveControl.Column(1) & """ is inactive, please choose another.", vbExclamation, AppName
        Screen.ActiveControl = Screen.ActiveControl.OldValue
        Screen.ActiveControl.Dropdown
    End If
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6395395
well...

why the 'B' ?

just curious...

cheers
Ricky
0
 

Author Comment

by:davidsanderson
ID: 6395622
the answer you gave wasnt exactly the code i ended up using, but it did lead me in the right direction, thanks bro!  everytime i give a B, i get the question of why.  does everyone else always give A's?
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6398498
well,

u can give whatever grade u want ofcourse, but most give A b/c the comments either led them in the right direction, or was right on the spot.
There have been lots of discussions about grading, but like i said most users give the A out of appreciating the free help they get. No matter if the problem was a brain-breaker or not.
Argument is that when not enough info is provided the questioner keeps asking and says the kind of grade they are planning to give, so the responders can adjust the comments ...

more info on grading : http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3

cheers
Ricky
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question