Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2007, 06:44 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change button caption on continuous subform

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:

Code:
Private Sub Form_Current()

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

End Sub
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
PT
 
Old April 16th, 2007, 08:00 AM
Authorized User
 
Join Date: Jan 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no to sure,but why dont uuse a field instead of a cmd button.the field will be in the subform table,so whenver the current record is deleted,or restored the field valued will change.
its the field that will bre programmed.

 
Old April 16th, 2007, 05:16 PM
Authorized User
 
Join Date: Mar 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi PT

As you have found, although the continuous form allows fields to vary from record to record, the definition of other screen objects is singular, and gets replicated across every record.

I've not tried it, but it seems to me that the best way round this would be to have two command buttons, cmdDelete and cmdRestore, both set to display in the same place, and make the appropriate one visible and the other invisible in the FormCurrent event procedure. This also means that you don't need to test the current state of the command button before deciding what to do when the button is clicked!

Give this a try, and report back...

RP






Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VB : How to change Label Caption papanchal Excel VBA 1 September 22nd, 2008 04:46 PM
Change Caption HtmlInputFile but it doest not upl. Israr HTML Code Clinic 1 April 25th, 2008 04:08 AM
Replicate 'group by' in continuous subform? PeregrinTook Access VBA 0 May 3rd, 2007 04:11 PM
Change Caption HtmlInputFile Israr ASP.NET 1.0 and 1.1 Professional 4 November 8th, 2006 02:32 AM
Counting Checkboxes On A Continuous Subform PC User Access VBA 4 April 26th, 2005 09:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.