Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2006, 03:52 PM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't disable the active control...

I have a form with buttons that I'd like to disable after they are pushed, like the save and the undo buttons, and then re-enable them after the data on the form is changed. When the user pushes either of these buttons, they receive the focus so I can't diable them while they have the focus. Instead of just sending the focus back to the first data field control, I implemented a "last active control" mechanism using a global variable of control type and the exit event's of the data entry fields.

When either of these buttons is pushed, I'm sending the focus back to the control stored in the global variable with the statement:

        Last_Active_Control.setfocus

This works well most of the time, but sometimes I am told that the assignment isn't valid, especially during debugging. Is there a way to check that the global variable has been assigned a valid control before making the trying to use it to set the focus?

Unfortunately, there doesn't seem to be an IsControl test in Access 2000's vba.

Thank you.
 
Old April 25th, 2006, 06:49 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What assignment is in the global variable when you are being told it isn't valid? What does the variable look like when it is valid?



mmcdonal
 
Old April 26th, 2006, 09:37 AM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When the form is opened, I assign the first combobox on the form to the global variable, then in each of the exit events of the enabled field controls, i.e., not the Save or Undo buttons, I update the global variable to the control that the user is exiting. The problem seems to occur after the degugger is invoked, but I'd really like to test the global veriable before I try to do a setfocus on it. The problem is I don't know how to test the global variable of control type to see if it is valid.

I created the global variable as:

    Dim Last_Active_Control As Control

I assign the global as:

    Last_Active_Control = Me.Unbound_Field_Control


 
Old April 29th, 2006, 07:47 AM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I finally figure out how to test the value of a control type variable.

You can't simply test using:

  If Ctrl = Nothing ...

You need to use:

  If Ctrl Is Nothing ...
     or
  If Ctrl Is Not Nothing ...
 
Old April 29th, 2006, 07:48 AM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So now I can test my global control variable before attempting to set the focus to it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Active Content in Browser setting taraprasad Pro JSP 0 February 1st, 2008 05:41 AM
Disable User control in Windows Sebastiaan VBScript 3 June 17th, 2007 04:20 PM
Disable side bar links of Wizard Control everest ASP.NET 2.0 Professional 0 February 14th, 2007 01:33 AM
How to disable PostBack for a button control? ashraf_gawdat .NET Framework 2.0 7 October 23rd, 2006 01:14 PM
I need control to resize other active windows danny1 Visual C++ 0 May 20th, 2005 01:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.