Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button Caption 1

Status
Not open for further replies.

psperry2

Programmer
Nov 7, 2007
141
0
0
US
I have a field called status in my persons table. It is a text field that can have 2 values (Active, Inactive).

I wanted to put a button on a form that would have as a caption the present value of the status field. Clicking on the button would toggle the value.

How can I get this field value displayed as the button caption?

I am using Access 2003 on an Access 2000 database.
 
In the btoon onclick event

If Me.Nameofbutton.Caption = "Active" then
Me.Nameofbutton.Caption = "Inactive"
else
Me.Nameofbutton.Caption = "Active"
end if

Have not tried it but it should work when you click it.



 
Sorry, btoon should read button
 
I think you will need a little more.

Code:
Private Sub cmdActive_Click()
  If Me.strActive = "Active" Then
    Me.strActive = "InActive"
  Else
    Me.strActive = "Active"
 End If
   Me.cmdActive.Caption = Me.strActive
End Sub

Private Sub Form_Current()
  Me.cmdActive.Caption = Nz(strActive, "Unassigned")
End Sub
 
Well the problem I am having is getting the Field Value from the table displayed as the Button Caption. I tried putting tblpersons.Status into the caption property but that didn't work as I hoped.
 
I called my field strActive yours is status.
 
I put in that code and it works great! Thanks MajP!
 
Sorry for my bit, assumed the button caption would have had a word Active or Inactive as a default, but now the story unfolded. Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top