Remove focus from command button

esskaykay

Registered User.
Local time
Today, 21:35
Joined
Mar 8, 2003
Messages
267
Hello,
Is there a way to remove the focus from a command button after the button has been clicked? I have a Form-A with a Button-B that only becomes visible is certain conditions exist. Button-B opens a second Form-B for additional input (Form-A is still open). Once Form-B is closed, I want Button-B on the Form-A to disappear.

I have this working as a “test button” on Form-A where if I click the Test button, it closes Button-B as I want. I tried setting my Test code on the OnLostFocus property of Button-B but it tells me I can’t close a control that has the focus.

TEST CODE:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RepaintObject
If Me.Grades = -1 Then
If Me.Request_No > 0 Then
Me.txtRequest_No.Visible = True
Me.cmdGrdRequest.Visible = False
Else
Me.txtRequest_No.Visible = False
Me.cmdGrdRequest.Visible = True
End If
Else
If Me.Request_No > 0 Then
Me.txtRequest_No.Visible = True
Me.cmdGrdRequest.Visible = False
Else
Me.txtRequest_No.Visible = False
Me.cmdGrdRequest.Visible = True
End If
Me.cmdGrdRequest.Visible = False
End If


Any suggestions would be greatly appreciated.
Thanks,
SKK
 
Try;
Code:
Me.ControlName.Setfocus

To set the focus to any other control before you hide the button.
 
I tried that but I was quite sure where to place the code. I tried it on the OnClick property of my button but that bombed. I believe the problem here is my second form is updating data in my current table. I'm gong to try creating a second query.

I may be back...
Thanks,
SKK
 
No I think its coming when I attempt to click on a second control. I now set the code in the forms OnDirty. This way it at least updates correctly once the user selects some other control. For now, this should be fine.

Thanks again,
SKK
 

Users who are viewing this thread

Back
Top Bottom