473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Previous Business Day

I am trying calculate the previous business day from today. I am
trying to use the code below i found on this site, but keep getting
error message when i try and compile, does not recognize rst.FindFirst.
I am using Access 2002:

Function funAddBusinessDay(datStart As Date, intDayAdd As Integer)
'Adds the proper Business day skipping holidays and weekends
'Arvin Meyer 05/26/98 with modifications by G. J. Shears 6/16/98
'Need to add holidays table using Hdate as field name of holidays
On Error GoTo Err_Hand2
Dim rst As Recordset
Dim db As Database
Dim strSQL As String
Dim h_test As Date
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT [hDate] FROM tblHolidays ORDER BY

[hdate] ", dbOpenSnapshot)
rst.FindFirst "[hDate] > #" & datStart & "#"
If rst.NoMatch Then
h_test = 0
Else
h_test = rst!hdate
End If
Do While intDayAdd > 0
datStart = datStart + 1
If WeekDay(datStart) <> vbSunday And WeekDay(datStart) <>
vbSaturday
Then
If h_test <> datStart Then
intDayAdd = intDayAdd - 1
End If
End If
If h_test = datStart Then
rst.FindFirst "[hDate] > #" & datStart & "#"
If rst.NoMatch Then
h_test = 0
Else
h_test = rst!hdate
End If
End If
Loop
funAddBusinessDay = datStart
Bye_Now2:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Function
Err_Hand2:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.Description
Resume Bye_Now2
End Function

Nov 13 '05 #1
2 3259
Simple answer. the last version of Access that used DAO by default was
Access97. Access 2000 and later use ADO by default. And no, there's
no way to override that. (I asked a long time ago, and MichKa said no,
get used to it.) You need to explicitly declare the recordset object to
be a DAO recordset, and either use late binding or register the DAO 3.6
library. Then it'll work like a champ.

So instead of:

Dim db as database
dim rs as recordset

you need to do

dim db as database 'doesn't matter - the Database object only exists in
DAO
dim rs as DAO.Recordset 'makes a HUGE difference- otherwise you get an
ADO recordset.

Nov 13 '05 #2
pi********@hotmail.com wrote:
Simple answer. the last version of Access that used DAO by default
was Access97. Access 2000 and later use ADO by default. And no,
there's no way to override that. (I asked a long time ago, and
MichKa said no, get used to it.) You need to explicitly declare the
recordset object to be a DAO recordset, and either use late binding
or register the DAO 3.6 library. Then it'll work like a champ.

So instead of:

Dim db as database
dim rs as recordset

you need to do

dim db as database 'doesn't matter - the Database object only exists
in DAO
dim rs as DAO.Recordset 'makes a HUGE difference- otherwise you get
an ADO recordset.


Or you can simply remove the ADO reference at the same time you add the one for
DAO.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
6
by: Paul Delhanty | last post by:
Hi, I am converting an existing native C++ program making heavy use of STL to C#2.0 with STL usage replaced by the new generic collections. The conversion has gone well to the point where I am...
5
by: G. Stewart | last post by:
The word "Business" in the term implies some sort of commercial aspects or connotations. But from what I can see, that is not necesserially the case at all? So what is the reasoning behind the...
1
by: David | last post by:
What I envision is this. The user gets a set of records in a data grid Then the user gets to select one of the rows to view the detail information about the record. Then instead of backing...
1
by: Jeff | last post by:
I need to place a "Previous Page" link on every page within my site and a simple javascript:history.back() will not work because I need it to capture the state of the page when I left it. For...
0
by: jalo | last post by:
I need help with this Macro. At the moment I can only use it for the one day specified ie the 1508 but need it to pick up the previous business day. Don't know if there is a simple remedy for this or...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
12
by: Michael.Z | last post by:
Anyone who can help: Given a Table.h file I am writing a Table.c file. I keep getting the compile error: previous declaration of Table was here / conflicting types for I think the...
4
by: gimme_this_gimme_that | last post by:
Is there a way to get the last day of the previous business quarter from DB2? For 10/21/2008 the day would be 9/30/2008. Thanks.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.