Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122

    Unanswered: Date control on form????

    I have a button on a form tht runs an update macro. I would like to put a text box on the form that changes each time you push the update button. I want to add a DATE including TIME to the textbox to show when the update has happened. I have tried and can't get passed this error...

    YOU CANT REFERENCE A PROPERTY OR METHOD FOR A CONTROL UNLESS THE CONTROL HAS THE FOCUS.

    My code looks something like this:

    If chkUpdateDR = True Then
    DoCmd.RunMacro "DiscrepancyReport" 'runs the macro
    chkUpdateDR = False 'resets the update checkbox
    Text46.Text = Now() 'updates the date&time
    End If


    Any ideas?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    simply drop the .Text in
    Text46.Text = Now() 'updates the date&time

    Text46 property then defaults to .Value (you can also specify .Value explicitly if you prefer)
    .Value does not require focus, .Text does

    .Text has it's value (sorry!) but not in your context.

    izy
    Last edited by izyrider; 05-01-06 at 14:43.
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    thanks! That worked perfect!


  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    good! ( and i already started the )

    a couple of general notes tho:

    unless you are specifically looking for the particular properties of .Text, don't use it, don't use anything! the default .Value handles 99% of the cases when you need to talk to a textbox

    unless you can memorise n-dimensional matrices in your head over decades with ease, don't accept Access' default naming for a text box. Text46 is an abominable name for a textbox: it offers zero hint as to what the textbox might contain.
    rename the thing to anything you like that doesn't have spaces in it
    mostRecentClickForNowTextBox
    is gruesomely ugly, but informative.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    I spoke to soon...

    Your suggestion works perfectly, IZY as long as i stay in the database. When i exit and then go back in the I lose the information. What i need is to have the textbox change and stay changed. That way when someone goes into the database they can see when it has been updated.

    Your right about the name of my Textbox- i will change it.

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Store the data into an additional field in your table. Call it perhaps: UpdateTimeStamp. Bind your textbox to it or use the SQL UPDATE statement within the BeforeUpdate event of you form....or... whatever.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  7. #7
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    I thought of doing that, and actually I have done that in the past but this time the situation is a little different. My form will have multipe (7) reports that will need to be updated. So , i have 7 buttons on my form and woould like to add the date and time next to each button, showing when it was pushed (updated) last. I was thinking of creating a table that records the update date and time for each macro and then link that table to my form and attach each appropriate field to each corresponding textbox. I thought of this yesterday but was hoping there would be an easier way...

    what do you think?

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i think you need a one-and-only-one-record table that contains a field for each of your update dates.

    when user does an update on date1
    strSQL = "UPDATE my1recTable SET fldDate1 = " & Now() & " WHERE myID=1;"
    currentdb.execute

    When the form loads and you are looking for the date to fill the txtbox
    myTxtBox = dlookup("fldDate1", "my1recTable", "myID=1")

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •