Update Time Continued

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

John (and anyone else):

This is what I now have:

Private Sub Form_Load()
Me.TimerInterval = 1000
End Sub

Private Sub Form_Timer()
Me!txtTime = time()
End Sub

(I have the timer as a text box because I've put it in
under the Insert Menu and that's how it comes in)
When it runs, it gives me this error:
"Microsoft Visual Basic
Run-time error '2448':
You can't assign a value to this object.
End Debug"

When I click on Debug, it highlights the line "Me!txtTime
= time()"

Why is this not working?!

Thanks again,
Melissa
 
Hi!!
In the private sub form_timer you need to change the
following Me!txtTime.. To ....

Me.txtTime.Value = time()

assuming that your txtTime is a txtBox.

I tried it on my computer and it seems to work fine.
HTH,
Patrick
 
Melissa said:
John (and anyone else):

This is what I now have:

Private Sub Form_Load()
Me.TimerInterval = 1000
End Sub

Private Sub Form_Timer()
Me!txtTime = time()
End Sub

(I have the timer as a text box because I've put it in
under the Insert Menu and that's how it comes in)
When it runs, it gives me this error:
"Microsoft Visual Basic
Run-time error '2448':
You can't assign a value to this object.
End Debug"

When I click on Debug, it highlights the line "Me!txtTime
= time()"

Why is this not working?!

Do you have txtTime bound to an expression already? If you want to set its
value in code it must be bound to a field or not bound at all. The latter
would be appropriate in your case.
 
Nope, same thing is happening. Exact same error. I even
tried renaming the textbox to have NOTHING to do with
time and then changing it in the code, and it's not
working. I'm just not getting this.

My procedure:
In Design View on the form, Pull down "Insert" then
Date/Time and pick just time (Medium format).
Move the box to where I want it to be and then open the
Properties for the textbox, rename it to "pink".
Then on the Form properties, in the "On Timer" box, click
the "..." to open the code.
The code is changed to read:
"Private Sub Form_Timer()
Me.pink.Value = time()
End Sub"
And then saved and closed.
Save the Form and push the button to see Form View. Wait.
Within a second, the error box pops up as before:
"Microsoft Visual Basic
Run-time error '2448':
You can't assign a value to this object.
End Debug"
Debug highlights this: "Me.pink.Value = time()"

I am running MS Office (Access) 2000 (9.0.3821 SR-1) on a
Windows XP Pro computer.

Am I doing something wrong??
Thanks again,
Melissa
 
Nope, same thing is happening. Exact same error. I even
tried renaming the textbox to have NOTHING to do with
time and then changing it in the code, and it's not
working. I'm just not getting this.

My procedure:
In Design View on the form, Pull down "Insert" then
Date/Time and pick just time (Medium format).
Move the box to where I want it to be and then open the
Properties for the textbox, rename it to "pink".
Then on the Form properties, in the "On Timer" box, click
the "..." to open the code.
The code is changed to read:
"Private Sub Form_Timer()
Me.pink.Value = time()
End Sub"
And then saved and closed.
Save the Form and push the button to see Form View. Wait.
Within a second, the error box pops up as before:
"Microsoft Visual Basic
Run-time error '2448':
You can't assign a value to this object.
End Debug"
Debug highlights this: "Me.pink.Value = time()"

I am running MS Office (Access) 2000 (9.0.3821 SR-1) on a
Windows XP Pro computer.

Am I doing something wrong??
Thanks again,
Melissa
 
Huh? I just put it in as a text box under the insert
menu. I don't think it's bound to anything.
Please see my reply to Patrick's for more info.

Thanks,
Melissa
 
Melissa said:
Nope, same thing is happening. Exact same error. I even
tried renaming the textbox to have NOTHING to do with
time and then changing it in the code, and it's not
working. I'm just not getting this.

When you tell Access to insert "Date and Time" then that is telling Access
to put an expression into the ControlSource of the TextBox. Once it has an
expression as its ControlSource you cannot then come along later in your
code and tell Access to put a new value in there.

Just forget about the "insert" menu and drop a plain ol' unbound TextBox on
your form. Then it will work.
 
No can do.
When I try to do this, if I leave the text box blank, it
disappears. If I type anything in it, then when I put it
in the code, it tells me:
"Compile error: Method or data member not found."
(Hhighlights the .value part of the statement)

The other way, it seems to be updating the time after I
push "End" on the error box, but I don't understand why
it's giving me the error in the first place, and I'd like
to get rid of it, as it's a multi-user database...

Thanks,
Melissa
 
Correction: the other way is NOT updating the time
either. I don't know why I thought it was.
 
Melissa said:
No can do.
When I try to do this, if I leave the text box blank, it
disappears.

If it disappears when you leave it blank then it is not a TextBox, it is a
Label. Access doesn't like empty Labels but is perfectly happy with
unbound TextBoxes.
 
Back
Top