Solved

MS Access 2003 Disable Button after Click Event

Posted on 2013-02-06
2
979 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
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
Comment Utility
Set focus elsewhere first:

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

Open in new window

0
 

Author Closing Comment

by:lrbrister
Comment Utility
Well...
Duh on me!  Thanks.

Another question coming
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now