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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change button caption on continuous subform

Status
Not open for further replies.

KanedNUnable

Technical User
Jul 16, 2006
4
GB
Hi all,

I have a master single form containing a current 'user' record, and a linked subform (continuous form) displaying all bookings for that user.

In the subform, next to each record is a command button. For each record, I want the command button's caption to either display 'delete' if the field 'deleted' has a value of 0 or 'cancel' if the field 'deleted' has a value of 1.

So far I have got this code:

[blue]
Private Sub Form_Current()

If Me.Deleted = 1 Then Me.btnDelete.Caption = "Restore" Else Me.btnDelete.Caption = "Delete"

End Sub
[/blue]

Which almost works!

The problem here is the subform might display twenty records, and the button caption only changes when you click a record - and in this case it changes the button caption next to every record to either read 'Restore' or 'Delete'.

I'm trying to make it so that as soon as the subform has been requeried, the buttons next to each record change automatically - so some in the list will say 'Restore' and some will say 'Delete'.

Is this possible?

Thanks
KanedNUnable
 
I don't think it is possible...

What you could do is...


Make 2 labels ..one that says "Delete" and one that says "Restore", then use Conditional Formatting.

if it is deleted then make the conditional formatting so that it makes the "Delete" disappear.. ( change the font color to match the back ground and disable it )

Apply similar rules to the other label.





Hope this helps!

Regards

BuilderSpec
 
Thanks for the reply BuilderSpec

I'm not sure if I followed you correctly, but I've devised a solution based loosely on what you suggested above...

I got rid of the command button and replaced it with a single unbound textbox, setting the control source to:

[blue]=IIf([Deleted]="0","Delete","Restore")[/blue]

I formatted the textbox to look like a command button, and the OnClick event checks for the value in field 'Deleted' then either calls the 'Delete' or 'Restore' function accordingly.

Many thanks!
PT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top