Solved

Remove bank holidays

Posted on 2008-09-30
15
597 Views
Last Modified: 2013-11-27
I have asked a similar question on here before but not quite got what I needed.

I want to set up a table (tblHolidays) that will contain public holidays for the year. I will then use a command button that will look to see if these dates are on my form and will change any that are to the next working day.

0
Comment
Question by:benissitt
  • 7
  • 6
  • 2
15 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22607299
you can use dlookup

if not isnull(dlookup("holidate","tblHolidays","[Holidate]=#" & dateVariable &"#")) then
'do your thing here

else


end if
0
 

Author Comment

by:benissitt
ID: 22607724
Would I need to apply that to each date that I have on my form?

So I would use..

if not isnull(dlookup("holidate","tblHolidays","[Holidate]=#" & dateVariable &"#")) then
txtDate1.value = DateAdd("d", 1, [txtDate1])
else
end if
0
 

Author Comment

by:benissitt
ID: 22625031
I have this working now.

However, I have an issue with the dateadd part. I need to it go to the next working day (just using dateadd("d",1,[txtdate]) could make the date land on a weekend
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 22644105
benissitt,

Try this:

Open the two tables: tblHolidays and tblBusyDays.
Notice that they have two days in common (Independence Day and Thanksgiving Day).
Using a calendar, calculate the Next Working Day for thoes two dates in tblBusyDays.
Close the two tables.
Open the query and view the SQL source, notice the nested IIF functions that do the calculations. Also note the innerjoin that finds the matching dated in both tables.
Close the query.
Open the form and click the button.
Now re-open tblBusyDays.
It should now have moved the BusyDayDate to the next working day.

I am sure you can adapt this to work in your database.

JeffCoachman

Access-EEQ23775297SkipToTheNextW.mdb
0
 

Author Comment

by:benissitt
ID: 22648025
Hi

Thanks for the response, I will be incorporating that in a future release.

I have a problem with the original suggestion made to me..

if not isnull(dlookup("holidate","tblHolidays","[Holidate]=#" & txtdate1 &"#")) then
txtDate1.value = DateAdd("d", 1, [txtDate1])
else
end if

It is not handling null in the way I expect. If I have null values on the form where the holidays are being removed, I get:

Run-Time error 3075

Syntax error in query expression '[Holidate]=##'

When I debug, it highlights the code for the first text box on the form that doesn't contain a value

Any thoughts?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22648486
benissitt,

Did you try my sample?

JeffCoachmamn
0
 

Author Comment

by:benissitt
ID: 22648690
I did look at it. The problem I have is that the dates on the form where the holidays need removing are unbound and there are a lot of them. Would I even be able to apply your sample to my database?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22650825
benissitt,

"Would I even be able to apply your sample to my database"
Possibly, you would have to post a sample.

JeffCoachman
0
 

Author Comment

by:benissitt
ID: 22651741
Hi

Here is a copy of what I am working with. There are a number of forms (monthlyschedule, bimonthlyschedule) that will have dates that need holidays removing from them.

The number of dates displayed on each schedule form depends on how many dates you enter into the main form (scheduledata).

As you can see from the remove weekends button on each form, I've had to go a very long way around achieving what I want. Please excuse my amateur coding skills! If you could suggest any way I could remove holidays that would be great. I am also looking to submit dates generated on the forms to a table, if you have any suggestions that would also be appreciated

Thankyou for your time

Ben
CopyofSchedules.zip
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22651808
benissitt,

you will get more response to your problems,
1. if you will limit your requirement to one per question
2. if the original problem is solved, close the thread by accepting the working solution.
3. open another question to the other requirement you want to do..

i, for one, does not like to be dragged to a series of problems in a single Q.
0
 

Author Comment

by:benissitt
ID: 22651939
Hi capricorn,

Point taken, apologies.

Any chance helping me out with the problem I have with your response to me then? :p

Thanks

Ben
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22653602
benissitt,

I will try to post something by tomorrw.

Jeff
0
 

Author Comment

by:benissitt
ID: 22655145
Thankyou very much Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22674891
benissitt,

The form is bount to the table.
If you created a query that worked the same as my sample, you could base the form on the query, and have the "Moved" dates displayed by default.

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22794197
;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question