Dlookup VBA for multiple dates

Joined
Nov 11, 2012
Messages
1
Reaction score
0
Dear All:
I have 2 Appointment tables. I managed to prevent the user from duplicating the data by using a Dlookup code. now I am trying to do the following:
1. prevent the user from duplicating the same appointments on each tables and,
2. avoid any conflicts between the 2 tables.
1st table; Name :AssComprcd which has [ID] Autonumber field, [ComDate] and [ComTime] (Date/time Format, Short)
2nd table; OR-Lab Prcd: which has ORLabPrcdID Autonumber field, [PrcdDate] and [Prcdtim] (Date/time Format, Short)

I tried to implement the first feature using the following code but it did not work:
On Error Resume Next
Dim appconf As Long
appconf = 0
appconf = DLookup("ID", "AssComprcd", "ID<>" & ID & _
" AND ComDate = #" & ComDate & "#" & " AND Comtime = #" & ComTime & "#")
'If appconf <> 0 Then
MsgBox "Previous Appointment Exists Already", vbCritical
Cancel = 1
Me.File_no.SetFocus
End If

Your Help is highly appreciated,
Regards
 
Back
Top