Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remove bank holidays

Posted on 2008-09-30
15
Medium Priority
?
606 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

604 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