Solved

Remove bank holidays

Posted on 2008-09-30
15
595 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Suggested Solutions

Title # Comments Views Activity
Modal form 11 31
Access query expression 6 22
Batch Export Reports (with multiple parameters) As PDF 2 25
Change date stored as "short text" YYYYMMDD to MM/DD/YYYY? 27 30
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 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