Time

  • Thread starter Thread starter Michael Mishler
  • Start date Start date
M

Michael Mishler

This should be simple:

I simply want to know the function to paste time into a text box:

I have:

txtTime.text = Time

I get: "Invalid use of null"


How can I paste the time in a text box?

Thanks!
 
Unlike VB, you set the Value of the text box, not its Text.
(Text is only available if the control has focus).

Me.txtTime = Time

Let's hope you don't have any other object (field, text box, ...) that is
also named "Time".

It may also help to use Option Explicit at the top of your module. Then
choose Compile from the Debug menu so Access can catch any misspellings or
misassignments.
 
Instead of Time, try using Now()...and then set the format
property of the text box to your preferred time format.
 
lose the .text value. It should be:
txtTime = Time

the .text only works if the text box currently has the
focus so why make it harder on yourself by specifiyng it
when omitting it works fine.

-Cameron Sutherland
 
If the textbox is unbound, put this expression in its control source property:

= Time()

If the textbox is bound, the bound field needs to be DateTime data type. Put
this code in an appropriate event:

Me!NameOfTextbox = Time()


--
PC Datasheet
A Resource for Access, Excel and Word Applications
(e-mail address removed)
www.pcdatasheet.com

· Design and basic development for new applications
· Additions, Modifications and "Fixes" for existing applications
· Mentoring for do-it-yourselfers who want guidance
· Complete application design and development
· Applications Using Palm Pilot To Collect Data And
Synchronize The Data Back To Access Or Excel
 
Michael,

Being a VB developer type myself, I prefer the explicit object syntax:

me.txtTime.value = time() 'control format set to appropriate time format
or
me.txtTime.value = now() 'control format set to appropriate time format

yeah, it's a little more verbose, but if I come back to an access
form coded like this after six months of doing VB/C#/VB.Net
etc.,. coding work and come back to this I instantly know what
is happening by reading the code without having to try and
remember what the dang default property name for a text box
control in Access is (.value).

- Mark

: This should be simple:
:
: I simply want to know the function to paste time into a text box:
:
: I have:
:
: txtTime.text = Time
:
: I get: "Invalid use of null"
:
:
: How can I paste the time in a text box?
:
: Thanks!
:
:
 
Back
Top