Prev: Tickbox Update
Next: laboratory data model design
From: Chai on 13 Apr 2010 10:39 I need a code that when I click on a button the command button says "Something", and when clicked again says "Something else", and so on and so forth, for example. Thank you!
From: Al Campagna on 13 Apr 2010 11:31 Chai, Try this sample code. Use your own object names... Note that two caption changes should also relate to two separate code actions. Private Sub cmdYourButtonName_Click() If cmdYourButtonName.Caption = "Something" Then cmdYourButtonName.Caption = "Something Else" ' *** You just clicked the Something button so... ' *** insert the Something code here... Else cmdYourButtonName.Caption = "Something" ' *** you just clicked the Something Else button so... ' *** insert the Something Else code here... End If End Sub -- hth Al Campagna Microsoft Access MVP 2007-2009 http://home.comcast.net/~cccsolutions/index.html "Find a job that you love... and you'll never work a day in your life." "Chai" <Chai(a)discussions.microsoft.com> wrote in message news:0ADD8FDD-5F97-452C-BEC0-3581519239DE(a)microsoft.com... >I need a code that when I click on a button the command button says > "Something", and when clicked again says "Something else", and so on and > so > forth, for example. > > Thank you!
From: Douglas J. Steele on 13 Apr 2010 11:33 Private Sub MyButton_Click() Select Case Me!MyButton.Caption Case "Caption1" Me!MyButton.Caption = "Caption2" Case "Caption2" Me!MyButton.Caption = "Caption3" Case "Caption3" Me!MyButton.Caption = "Caption1" Case Else Me!MyButton.Caption = "ERROR" End Select End Sub -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "Chai" <Chai(a)discussions.microsoft.com> wrote in message news:0ADD8FDD-5F97-452C-BEC0-3581519239DE(a)microsoft.com... >I need a code that when I click on a button the command button says > "Something", and when clicked again says "Something else", and so on and > so > forth, for example. > > Thank you!
|
Pages: 1 Prev: Tickbox Update Next: laboratory data model design |