If statement help

coolcatkelso

Registered User.
Local time
Today, 13:24
Joined
Jan 5, 2009
Messages
279
Hiya

I have a calendar in my DB and as a trademan we only work 8 hours per day. In my form there is an option to add the appointment to the calendar.

What I want is an IF statement to lookup the calendar, and IF there are 8 records (8 hours) in that date then give a popup to say the day is fully booked?

Is there a simple IF statement that I can use? Not too good with the coding side of access yet
________
AVANDIA LAW
 
Last edited:
Hiya Kelso,

Without knowing your specific tables etc.:

Code:
If DCount("[YourDateField]", "YourTable", "[YourDateField] = #" & Me.DatePicked & "# And Employee = " & Me.EmployeeID) = 8 Then
   MsgBox("That Day Is Booked.")
End If

hth,
Wayne
 
Hiya


Cheers for the reply

That code makes sense, would I just put it in the calendar form or the form to add the date to calendar?
________
BODY SCIENCE
 
Last edited:
Kelso,

Hard to tell without seeing it.

I'd imagine that you'd want to use the Control's BeforeUpdate event,
Canceling the entry if the DCount returns 8.

Wayne
 
Hiya again

Cheers for the update

I tried your code but it picks up an error on Me.DatePicked

Compile Error:
Method or datamember not found

I'll include the DB this time lol

The main form will open automatically. You then click on Quotes, View Quotes, Add to Calendar button and thats the form for entering the date into the calendar

Dependat forms & Tables are

tbl_Dates (main Table)
Times (Look up table for entering the Duration)
Dates_subform - Main form in the calendar view
Frm_Calendar (Actual Calendar and end product of everything)

THe form - Calendar is built from the tbl_Dates
The feilds are
Date (With Date picker)
Customer (Lookup from main Customer table)
Team (Lookup from Teams Table)
Appointment (Lookup from table Appointments)

Date is the one that I want to filter on, and once the date has been picked it should then check the Duration, either 1, 2, 3 4, etc hours Maximum 8 hours

I have a sum runnin in the Dates_subform counting the number of hours in each day, so I guess that would be the field to add your code behind.

If the sum is 8 msq This day is full

:D

Your help is much appreciated

Cheers m8
________
IOLITE PORTABLE VAPORIZER SIZE
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom