Solved

MS Access 2003 Disable Button after Click Event

Posted on 2013-02-06
2
1,089 Views
Last Modified: 2013-02-06
I have a Button on a form and a VBA Click Event

The code is below...
Getting error message, "Cannot disable control while it has the focus."

How do I handle this?

I need to disable this button so it can only be clicked once.

Private Sub cmdCreateDefaultHours_Click()
    Dim cmd As New ADODB.Command
    Dim rst As New ADODB.Recordset
    cmd.ActiveConnection = Conn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "HoursTrackingLoadDefaultHours"
    cmd.Parameters("@hoursTrackingID") = Me.txtHTID
    Set rst = cmd.Execute()
    MsgBox rst!msg

'This next line fails
   Me.cmdCreateDefaultHours.Enabled = False
End Sub

Open in new window

0
Comment
Question by:lrbrister
[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
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38860394
Set focus elsewhere first:

Me.SomeOtherControl.Setfocus
Me.cmdCreateDefaultHours.Enabled = False

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 38860490
Well...
Duh on me!  Thanks.

Another question coming
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

687 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