Solved

Remove bank holidays

Posted on 2008-09-30
15
594 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 119

Expert Comment

by:Rey Obrero
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
 
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 119

Expert Comment

by:Rey Obrero
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ms Access Many To Many Relationship Explantion Help Please 5 41
DSum for Access 6 47
Importing and Dropping Table in Access 11 24
append to an ms access field 6 25
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

896 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now