Connecting Tech Pros Worldwide Help | Site Map

Display an Alert

  #1  
Old November 17th, 2008, 08:25 AM
Naushad
Guest
 
Posts: n/a
Hi All

Our Company is provided courses to employees for one or more days i.e.
there are three field (EmpNo, StartDate and EndDate) of course. I am
trying to display an Alert message when a perticular employee has to
attend a new course If he is busy in the other course between these
two dates.

Thanks in advance

Naushad
  #2  
Old November 17th, 2008, 01:55 PM
Allen Browne
Guest
 
Posts: n/a

re: Display an Alert


You have an overlap between event A and event B if:
- A starts before B ends, AND
- B starts before A ends, AND
- it's the same employee, AND
- it's not the same event.



To achieve the 4th part, you will need a primary key in your table.
The example below assumes an AutoNumber primary key named ID.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim varResult As Variant
Const strcJetDate = "\#mm\/dd\/yyyy\#"

If ((Me.EmpNo = Me.EmpNo.OldValue) AND _
(Me.StartDate = Me.StartDate.OldValue) AND _
(Me.EndDate = Me.EndDate.OldValue)) OR _
IsNull(Me.EmpNo) OR _
IsNull(Me.StartDate) OR _
IsNull(Me.EndDate) Then
'do nothing
Else
strWhere = "(EmpNo = " & Me.EmpNo & ") AND (StartDate <= " & _
Format(Me.EndDate, strcJetDate) & ") AND " & _
Format(Me.StartDate, strcJetDate) & _
" <= EndDate) AND (ID <" & Me.ID & ")"
varResult = DLookup("ID", "Table1", strWhere)
If Not IsNull(varResult) Then
Cancel = True
MsgBox "Clashes with event id " & varResult
End If
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Naushad" <nhaider@kockw.comwrote in message
news:b34198bd-a6da-4e88-b59d-edefe044a1a1@r36g2000prf.googlegroups.com...
Quote:
Hi All
>
Our Company is provided courses to employees for one or more days i.e.
there are three field (EmpNo, StartDate and EndDate) of course. I am
trying to display an Alert message when a perticular employee has to
attend a new course If he is busy in the other course between these
two dates.
>
Thanks in advance
>
Naushad
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX does not work without an alert knkk answers 8 December 29th, 2008 09:41 PM
display an alert only once AAaron123 answers 11 August 11th, 2008 02:35 PM
how to display an alert message in ajax cmrhema answers 1 February 26th, 2008 04:59 PM
unable to do an alert for a radio button value yawnmoth answers 4 October 20th, 2006 01:05 AM