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 August 29th, 2005, 07:37 PM
Authorized User
 
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default Control button caption and visible property

Hi,

This is a two part question:

1) I have a continuous form that is a result of several queries. I would like to add a control button that opens a specific form (that part I have no problem with), but I want the caption to be the value of one of the query fields. I tried to right-click on the said field (text box) to replace it with a control button, but it doesn't allow me to do it. How can I go about this.


2) If the value of the text box is null, I don't want the control button to be visible.

Thank you

Chantal

 
Old August 30th, 2005, 07:27 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

2. Set the visible property of the button to No.
Put this code on the Form's On Current event:
'-----
If IsNull(Me.Textbox) Then
   Me.btnButton.Visible = False
   Else
   Me.btnButton.Visible = True
End If



mmcdonal
 
Old August 30th, 2005, 07:33 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

1. Add the button to the form in Design view. This button will show up in each section of the continuous form. Leave the caption blank
On the form's On Current event, put this code:
'----------
Me.btnYourButton.Caption = Me.txtYourTextField
'----------
This will put the value of the text field as the button's caption.
Set the Visible property of the field to No and leave it on the form.

HTH



mmcdonal
 
Old August 30th, 2005, 07:35 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

That is, set the vsible property of the text field to No and leave it on the form.

mmcdonal
 
Old September 5th, 2005, 08:51 AM
Authorized User
 
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default

Hi,

This works partially. All 125 records of the continuous form have the same button with the same caption i.e. the value of the record that has the focus (for example 9). Hence, when the focus goes to another record, all 125 buttons' caption change to 5. With the next record, the buttons are all invisible, etc...

Do you know how I can fix this ?



 
Old September 7th, 2005, 07:32 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I would not have the caption be dynamic then. Why do you need the caption to have a field value on it. Buttons generally have captions that explain their function, not the value being passed.



mmcdonal
 
Old September 9th, 2005, 10:59 AM
Authorized User
 
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default

To save some space on the form... right now, i have a text field with the value (for example = 5) and a control button right next to it, to open a form that displays the "5" records...

 
Old September 9th, 2005, 11:14 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

But you can do this without changing the caption each time the value in the text field changes.
Just put the button next to the field and have a caption that works for all values.

For example, I have a form where users can look for a customer in the database, and then click a button that opens a form that displays the customer data. The label above the text box says "Find a Customer Last Name, First Name" then there is a button below the text box that says "View this Customer's data"
The user knows by this that they have to select a customer first and then click the button to see the data.
You can also check the value in the text box and do a constraint if the value is wrong.
In my case, the field is a look up to the customer table. So if the field is null (IsNull) then the user is prompted to enter a name and the action is cancelled.

HTH

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Button does not retain visible property mhshpk ASP.NET 2.0 Professional 2 July 18th, 2007 11:24 AM
Alter Table and Caption Property swoozie Access 0 May 24th, 2006 12:38 PM
Word.ApplicationClass Visible Property danielv General .NET 0 January 11th, 2006 12:50 PM
Visible row property Louisa VB.NET 2002/2003 Basics 0 October 29th, 2004 04:26 AM
Visible property glitch bmains VS.NET 2002/2003 3 May 5th, 2004 02:36 PM





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