H
HeislerKurt
My main form holds patient information (tblPatients), and my subform
holds daily information (tblDailyData) collected for each patient.
(Hence, a one-to-many.)
An individual patient should not have the same date entered twice, so
on the subform, in the BeforeUpdate event of the date control, I need
to check for a duplicate date. Right now my code looks like:
If DCount("DailyDate", "tblDailyData", "DailyDate= #" & Me.DailyDate &
"#") > 0
Then
Me.Undo
MsgBox "Sorry! This date has already been entered.",
vbExclamation, "Duplicate Date"
End If
But obviously this just checks for duplicate dates in tblDailyData.
Instead, I need to check for a duplicate date WHERE PatientID =
Me.PatientID.
Do I need to rewrite this with a SQL string, or can DCount handle
something like:
If "tblPatients.PtID, DCount('DailyDate', 'tblDailyData', 'DailyDate=
#' & Me.DailyDate & '#') > 0 " & _
"From tblPatients " & _
"INNERJOIN tblDailyData " & _
"ON tblPatients.PtID = tblDailyData.PtID " & _
"WHERE tblPatients.PtID=" & Me.PtID Then
The above code gives me type mismatch error.
Thank you for any pointers.
Kurt
holds daily information (tblDailyData) collected for each patient.
(Hence, a one-to-many.)
An individual patient should not have the same date entered twice, so
on the subform, in the BeforeUpdate event of the date control, I need
to check for a duplicate date. Right now my code looks like:
If DCount("DailyDate", "tblDailyData", "DailyDate= #" & Me.DailyDate &
"#") > 0
Then
Me.Undo
MsgBox "Sorry! This date has already been entered.",
vbExclamation, "Duplicate Date"
End If
But obviously this just checks for duplicate dates in tblDailyData.
Instead, I need to check for a duplicate date WHERE PatientID =
Me.PatientID.
Do I need to rewrite this with a SQL string, or can DCount handle
something like:
If "tblPatients.PtID, DCount('DailyDate', 'tblDailyData', 'DailyDate=
#' & Me.DailyDate & '#') > 0 " & _
"From tblPatients " & _
"INNERJOIN tblDailyData " & _
"ON tblPatients.PtID = tblDailyData.PtID " & _
"WHERE tblPatients.PtID=" & Me.PtID Then
The above code gives me type mismatch error.
Thank you for any pointers.
Kurt