Results 1 to 6 of 6
  1. #1
    Janoose is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7

    Smile Saving Change to Text Caption During Run-time


    I was wondering if there was any way to save changes to label caption during run-time. Basically on the form the user has many options to select. Each option opens a new form. For one particular option, I have a label that displays the current date when the user chooses this option. However I cannot save this change to the label. When I reopened the form, the label reverts to its default text.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    You can certainly set up a label, and have it display today's date.
    Here's a sample on the Form's On Current event
    Private Sub Form_Current()
    Label21.Caption = Date
    End Sub
    If you set it up like this, it would be available when you open or reopen the form.

    If this isn't what you're looking for, please describe what exactly you need.

  3. #3
    Janoose is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    Private Sub Form_Current()
    Label21.Caption = Date
    End Sub
    I actually have that. My problem is saving the date when I closed the form. So when I closed and re-opened the form, the date disappears. My co-worker says to create a table just to save the date.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    What Date do you want?

    Date will always be today's date. If you want to save a date-- eg the date you were working on something -- then you need a way to save it (table or file).

    What do you mean the Date disappears?
    In my example, as long as you're working on a current record Today's date will be there.

    What am I missing?

  5. #5
    Janoose is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    The date isn't the problem. The real problem is how do I save the date into the caption label. I have posted screenshot. So BeforeDate.jpg is the default and what is looks like when I close and re-opened the form. The WithDate.jpg is what I want to save but wouldn't let me save.

    I have used ACSave something like that and even ACSaveyes not sure if I was using them properly.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I have talked to a few colleagues and tried a few things myself. I suppose you could create a new process to open the form in design mode and make changes and save it.
    But I think the easiest way, that you can do right in a Form event is as follows.

    Save the date you want to use to a Table.
    Create a Form_Load() event
    In that event put in code along these lines

    Private Sub Form_Load()
    Dim myDate As Date
    myDate = DLookup("deathdate", "ancestor", "name = '" & "Jim" & "'")
    Label21.Caption = "This form was last used on: " & myDate
    End Sub
    NOTE: I just used an existing table to get a Date that had been saved

    You could do a DLookup using your table and field name

    That seems to be the easiest way - no special process. It's available immediately when Form is Loaded.
    You will need to save a Date to your table when /where appropriate.

    Hope this is useful.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Saving Module Code to Text Files
    By ioMatt in forum Modules
    Replies: 2
    Last Post: 07-02-2011, 08:18 AM
  2. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  3. Handling Inventory Costs That Change Over Time
    By mubtuhogar in forum Database Design
    Replies: 5
    Last Post: 10-12-2010, 09:19 AM
  4. Run-time 339 when change to 2007
    By nivek in forum Access
    Replies: 1
    Last Post: 06-30-2010, 08:40 PM
  5. Subform Change - Run-time error 2101
    By Cheshire101 in forum Forms
    Replies: 3
    Last Post: 12-21-2009, 12:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums