PDA

View Full Version : Solved: Can a command button do 2 actions at the same time?



wedd
09-23-2011, 05:13 AM
Hi, I would like to create a button that firstly on click becomes hidden and displays text such as new customer in red on a form? Is this possible to using vba in access 2007? If so, how can this be done? Would you have any sample code on how to do this?


Thanks for your contributions:friends:

HiTechCoach
09-24-2011, 12:49 PM
Before a command button can be set to hideen or disables you must first move the focus to another control.

' move focus to another control
Me.OtherControlbName.Setfocus
' Hide control
Me.CommandButton.Visible = false

wedd
09-26-2011, 03:46 AM
Thank you sir!

wedd
09-26-2011, 04:18 AM
Hi HiTechcoach, if I wanted the command button to be invisible and display a textbox that is hidden, before the click event: would I need to write me.othercontrolname.text? What I want to hapen is that the user clicks on the button which beomes hidden, and then a textbox that was hidden is displayed...

HiTechCoach
09-26-2011, 07:39 AM
Set the visible property of a control to make it visible or not.


Try:

' move focus to another control
Me.OtherControlbName.Setfocus
' Hide command button
Me.CommandButton.Visible = False
' display text box
Me.txtMyTextboxControlName.Visible = True

wedd
09-27-2011, 03:37 AM
Great, it works! Thank you, HiTechCoach!

HiTechCoach
09-27-2011, 07:13 AM
You're welcome.

Glad we could assist.

Cheers.