If else then.... statement help

Chimp8471

Registered User.
Local time
Today, 21:43
Joined
Mar 18, 2003
Messages
353
I was advised to solve this problem using the vb aspect but i honestly aint got a clue, so am really hoping somebody can offer me some big help here...

for a college project i have had to design a database that monitors personnel data, which i have done, but just need a few things sorted, one of which is and if problem.

one of the boxes on my form displays the number of days holiday the employee has remaining, however this figure is not allowed to drop below zero, for obvious reasons.... which it is currently doing....

so i need to prevent this figure going below zero, when booking holidays on the form...

i also need it to flag a message in the event that to much holiday is attempted to be booked.

Can anybody please help me with this problem

cheers

Andy
 
You can do this a couple of ways.
The easiest but with less control is to set the validation rule on the 'holidays remaining' control on the form to >=0 and the validation text to whatever you want.

The other (coded) way is as you suggest with an if..then statement.

I assume you have a textbox / subform where you enter the days / dates requested and that updates the holidays. If you have a simple subtraction that updates the days then the coding is easier.
If you have a subform that logs all the dates taken, it is a bit more complex but the principle is essentially the same.

Post back how you enter the holidays currently and a solution will be easier to post back.
 
thanks for your help.

i have a text box [text100] called Remaining.

the information displayed in this box is taken from a subform.

the subform is made up of a number of things.....

Date holiday booking was processed called "Date Booked"

2 column, Start Date and End Date of holidays

and a column called Duration.

the employee is entitled various amounts of holiday depending on their length of service but this is all working ok.

so

from the entitlement i subtract the duration to get the remaining.....again this all works fine, up to the point of stopping the beyond zero problem.

Hope this has mad eit a little clearer

Andy
 
Do you keep a record of all the holidays requested in the subform? and is the subform in continuous mode, datasheet or normal form mode? eg

Start Date___End Date Duration
1/4/03______7/04/03____7
14/4/03_____16/4/03____2

etc

Is the data in [text100] dynamically generated or is it a static figure altered via a calculation?

I know I'm asking more questions but it gives a better idea how to best solve the problem.:)
 
ask as many questions as ya like just grateful for the help,

the holidays booked are stored in a table called 'Table1'

the subform is a continuos form

Start Date___End Date Duration
1/4/03______7/04/03____7
14/4/03_____16/4/03____2

the data in [text100] is generated as a result of a calculation
after i click a button which simply refreshes the form, after running a simply macro....the macro simply goes to the next record and back again.

hope this helps

Andy
 
Ok, that makes it clearer. Essentially you want to intercept the End Date, check if there is enough holiday left then if so, book the holiday and let it be saved?

Here is a very rough and ready and rushed (as it's hometime!) demo.
 

Attachments

Can i but in and ask a question

i just wanted to know if it is possible to number the lines of vb code in a project and whats the best way of doing this- also for a college project.
 
I dont know this one Thunder but I would post it as a new topic for a better response.
 
A word from the wings

Hi Fizzio

A fan offers praise. It looks good, and pretty efficient. Will Chimp mention you in his homework report, I wonder. Cheers from Warwickshire.

Kupe
 
Numbered lines

Hi ThunderBolt

Good question, particularly if you're used to coding in places like Dreamweaver, then you'll know how useful it is. Access has the VB line-numbers on the menu bar, but it would be handy to see the lines themselves numbered.

Cheers

Kupe
 
i haven't had a chance to check out the help offered here, but i will make reference to all help recieved.........thanks again to all

i dunno wot i'd do without these forums

Chimp
 
hi i have had a look at this code thing but am really struggling, if i have attached my databas for you to look at and hopefully sort this out........

to open the section i am having problems with click onnthe personnel data button then you will need to click on the holiday tab when it opens,

Help...................................


Cheers

Andy
 

Attachments

cheers "Fizzio" you are a star, many thanks

Andy
 

Users who are viewing this thread

Back
Top Bottom