Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Access 2003 Disable Button after Click Event

Posted on 2013-02-06
2
Medium Priority
?
1,120 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 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