Access 2000 and 2002 time error

  • Thread starter Russ via AccessMonster.com
  • Start date
R

Russ via AccessMonster.com

Trying to hold the time, but keep getting an error. What am I doing wrong?
Error can't find project

Dim TimeSet As String

'Set and hold current time
TimeSet = Format(Time, "hh:mm")

'Get left 2 numbers
TimeSet = Left$(TimeSet, 2)

Any ideas?
 
G

George Nicholson

I don't get an error, so I don't know what to tell you (what error do you
get??).

However, here is an alternative approach to what you seem to be doing:

TimeSet = Format(Hour(Time),"00")

Returns the current hour value as a 2 character string (with leading zero)

HTH,
 
K

Klatuu

In your VBA editor, click on Tools->References and see if you have any that
are identified as "Missing". I do not know which library might be necessary
for date/time functions. Are you having any trouble using any other date or
time functions?
 
R

Russ via AccessMonster.com

Thanks, but giving the same error;
Comile error;
Can't find project or library.

References are in this order;
Visual basic for applications
Microsoft Access 10.0 object library
OLE automation
Microsoft ActiveX data objects 2.1 library
Microsoft Visual basic for applications extensibility 5.3
Microsoft Common dialog control
Microsoft DAO 3.6 object library

thanks...
 
K

Klatuu

Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003 environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a difference.
 
R

Russ via AccessMonster.com

Klatuu,
Do you know the logic behind the order they should be in?
Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003 environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a difference.
Thanks, but giving the same error;
Comile error;
[quoted text clipped - 19 lines]
 
K

Klatuu

No, I do not. I have had it happen to me twice that I got a reference error,
so I moved what I thought was the offending reference higher in the list and
it worked.

Russ via AccessMonster.com said:
Klatuu,
Do you know the logic behind the order they should be in?
Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003 environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a difference.
Thanks, but giving the same error;
Comile error;
[quoted text clipped - 19 lines]
Returns the current hour value as a 2 character string (with leading zero)
 
G

George Nicholson

Russ: Do any of those references have "MISSING" next to them? (and unless
you are using the Common dialog control (very buggy) or VBA extensibility
(manipulating code via code) you can uncheck those).

Re the order. With one exception, I don't think it matters. DAO before ADO
(or vice versa) is the only case I know of where the "order" might make a
difference in compilation because they both have some, but not all, object
names (e.g., Recordset) in common. If the project code is DAO based and
hasn't been disambiguated ("Dim rst as DAO.Recordset" rather than "Dim rst
as Recordset"), putting the DAO reference ahead of ADO might gloss over some
problems.
I do not know which library might be necessary for date/time functions.
VBA, but it doesn't matter. Any Missing reference will prevent compilation.
The fact that it errored on a VBA function is almost always misleading.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


Klatuu said:
No, I do not. I have had it happen to me twice that I got a reference
error,
so I moved what I thought was the offending reference higher in the list
and
it worked.

Russ via AccessMonster.com said:
Klatuu,
Do you know the logic behind the order they should be in?
Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003
environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a
difference.

Thanks, but giving the same error;
Comile error;
[quoted text clipped - 19 lines]

Returns the current hour value as a 2 character string (with leading
zero)
 
K

Klatuu

Good catch, Geroge! It was the DAO ADO order that I had problems with.

George Nicholson said:
Russ: Do any of those references have "MISSING" next to them? (and unless
you are using the Common dialog control (very buggy) or VBA extensibility
(manipulating code via code) you can uncheck those).

Re the order. With one exception, I don't think it matters. DAO before ADO
(or vice versa) is the only case I know of where the "order" might make a
difference in compilation because they both have some, but not all, object
names (e.g., Recordset) in common. If the project code is DAO based and
hasn't been disambiguated ("Dim rst as DAO.Recordset" rather than "Dim rst
as Recordset"), putting the DAO reference ahead of ADO might gloss over some
problems.
I do not know which library might be necessary for date/time functions.
VBA, but it doesn't matter. Any Missing reference will prevent compilation.
The fact that it errored on a VBA function is almost always misleading.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


Klatuu said:
No, I do not. I have had it happen to me twice that I got a reference
error,
so I moved what I thought was the offending reference higher in the list
and
it worked.

Russ via AccessMonster.com said:
Klatuu,
Do you know the logic behind the order they should be in?

Klatuu wrote:
Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003
environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a
difference.

Thanks, but giving the same error;
Comile error;
[quoted text clipped - 19 lines]

Returns the current hour value as a 2 character string (with leading
zero)
 
A

Allen Browne

Why a string variable, Russ?

Use a Date variable to hold the value as a date/time type, or use an Integer
variable if you just want the hour. You can then perform any math needed on
the time or hour:

Dim TimeSet As Date
TimeSet = Time

Dim intHour As Integer
intHour = DatePart("h", Time)
 
P

Peter R. Fletcher

That should only cause problems, as George suggests, if you don't
disambiguate your potentially ambiguous DAO/ADO, ahd you really should
be doing that, anyway.

Good catch, Geroge! It was the DAO ADO order that I had problems with.

George Nicholson said:
Russ: Do any of those references have "MISSING" next to them? (and unless
you are using the Common dialog control (very buggy) or VBA extensibility
(manipulating code via code) you can uncheck those).

Re the order. With one exception, I don't think it matters. DAO before ADO
(or vice versa) is the only case I know of where the "order" might make a
difference in compilation because they both have some, but not all, object
names (e.g., Recordset) in common. If the project code is DAO based and
hasn't been disambiguated ("Dim rst as DAO.Recordset" rather than "Dim rst
as Recordset"), putting the DAO reference ahead of ADO might gloss over some
problems.
I do not know which library might be necessary for date/time functions.
VBA, but it doesn't matter. Any Missing reference will prevent compilation.
The fact that it errored on a VBA function is almost always misleading.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


Klatuu said:
No, I do not. I have had it happen to me twice that I got a reference
error,
so I moved what I thought was the offending reference higher in the list
and
it worked.

:

Klatuu,
Do you know the logic behind the order they should be in?

Klatuu wrote:
Here is what I have:
Visual Basic for Applications (probably not it)
Microsoft Access 11.0 object library (because I am in a 2003
environment)
Microsoft DAO 3.6 object library
OLE Automation
Microsoft Visual Basic for Applicatons Extensibility 5.3
Microsoft OUtlook 11.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft PowerPoint 11.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Also, I have found that the order in which the appear can make a
difference.

Thanks, but giving the same error;
Comile error;
[quoted text clipped - 19 lines]

Returns the current hour value as a 2 character string (with leading
zero)

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Top