Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 29th, 2005, 07:37 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
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

Reply With Quote
  #2 (permalink)  
Old August 30th, 2005, 07:27 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old August 30th, 2005, 07:33 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #4 (permalink)  
Old August 30th, 2005, 07:35 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #5 (permalink)  
Old September 5th, 2005, 08:51 AM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
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 ?



Reply With Quote
  #6 (permalink)  
Old September 7th, 2005, 07:32 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #7 (permalink)  
Old September 9th, 2005, 10:59 AM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
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...

Reply With Quote
  #8 (permalink)  
Old September 9th, 2005, 11:14 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:25 AM.


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