Lost Focus??

GregSmith

Registered User.
Local time
Today, 17:47
Joined
Feb 22, 2002
Messages
126
I have a command button that when you press it allows you to create a new record. How can I disable the command button after to press it?

I am using: Me.AddNewRecord.Enabled = False right now, but it comes back with an error that I cannot disable the selection because it has focus.

How can I make it lose the focus?
 
Wondering why you would want to disable the button, when would you enable it again so the next record can be entered? Anway, in answer to your question you would do something like:

DoCmd.GoToRecord , , acNewRec
Me.anotherfieldname.setfocus
Me.AddNewRecord.Enabled = False

HTH
 
Got kind of the same problem... In my case it's like this:
I got a form with 2 input boxes, a subform with 2 command buttons (that are disabled by default), and a second subform. As soon as one of the input boxes is filled in, the second subform shows the fields of a query (based on the filled in data) and the 2 commands buttons on the other subform are enabled.
The user then presses one (or two) of the buttons, depending on the situation...
After that he (or she ;) ) returns to the input boxes and fills in another value. At the moment of return (when one of the input boxes gets the focus) I want the command buttons disabled again but when using the SetFocus to the second button and trying to disable the first (or the other way around) it says me it cannot move the focus to the property :(
 
All you have to do is move focus to another control then you can disable. Look at DBL's post.
 
Jerry Stoner said:
All you have to do is move focus to another control then you can disable. Look at DBL's post.
That's what I did, i moved the focus to the second button and then tried to disable the first button but it didn't work, it said: "Can't move focus"
 
If the other button is default Enabled =false, you won't make it gain the focus.

You must enable that button first and then set the focus.

Dave
 

Users who are viewing this thread

Back
Top Bottom