Subject: saving changes to label caption
Posted By: Loralee Post Date: 1/4/2006 9:26:56 PM
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

Reply By: SerranoG Reply Date: 1/5/2006 9:45:26 AM
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
Reply By: Loralee Reply Date: 1/5/2006 9:08:28 PM
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

Reply By: Loralee Reply Date: 1/5/2006 11:48:06 PM
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

Reply By: SerranoG Reply Date: 1/6/2006 7:55:23 AM
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
Reply By: Loralee Reply Date: 1/6/2006 8:53:36 PM
Okay, Thank. I was just trying to keep from adding another table, and thought the caption property from a label would do it.

Thanks!


Go to topic 37964

Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394
Return to index page 393
Return to index page 392