Solved

Remove bank holidays

Posted on 2008-09-30
15
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

738 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