Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 January 4th, 2006, 10:26 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default saving changes to label caption

Could someone steer me in the right way please?

I have an unbound dialog form that has a label on it. I want to SAVE a date as the caption on a label.

(The user enters dates into text boxes. When they click a button the text property of the text box becomes the caption property in a label control. Simple enough, except when I close out the form the caption property of the label resets. How can I get the caption of the label to persist? (I tried adding the acsaveyes argument to the close method of the docmd, and that did not do it).

Thank you,

Loralee

 
Old January 5th, 2006, 10:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Hi, Loralee.

The reason it resets is that the caption is unbound an is something that is set in the form's design view. If you want the caption to change, you can do that via VBA code, of course. Now if you want it to ALWAYS reflect the date in another textbox, then you have to put VBA code on the form's ON CURRENT event code. If you don't the label will always "reset" back to what it was in the design view.

I'm going to make up names. I'll call the textbox with the date in it txtDateBox. Sometimes it will have a date and sometimes not. When there is no date, I'm going to assume you want the label to be today's date. I'll call the label that you want changed lblLabel. In the form's ON CURRENT event you want.

Me.lblLabel.Caption = Nz(Me.txtDateBox, Date())

This will constantly change the label to reflect a date in the textbox or today's date if there is no date in the textbox. You can change that to whatever you want. Just replace Date() with the default value you want if the date textbox is null.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 5th, 2006, 10:08 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Greg,

COOL- It works like a charm! I added txtTextbox = "" as the second line and it behaves exactly as I was trying to make it.

Thank you, Again,

Loralee

 
Old January 6th, 2006, 12:48 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Oops, I didn't play long enough. It doesn't really cause the information to PERSIST as the caption of the label once the app is closed. Short of creating a table, any other ideas?

Loralee

 
Old January 6th, 2006, 08:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Well, no. The labels in a form are not meant to work that way. If you want something to be STORED then you must save them as text fields in a table. On the form, you'd create a TEXTBOX and make it "look" like a label by using the properties to make it flat (not sunken), change its backstyle to transparent, and remove its borders.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 6th, 2006, 09:53 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Okay, Thank. I was just trying to keep from adding another table, and thought the caption property from a label would do it.

Thanks!






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
Checkbox Caption brian189 Access VBA 3 May 25th, 2007 07:05 AM
Caption Field Brendan Bartley Access 2 June 2nd, 2006 07:24 AM
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM
caption jlnashrod Access VBA 2 April 5th, 2004 10:48 PM





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