| re: Syntax in DCount function
Geoff wrote:[color=blue]
> FrmBookings is a subform linked to the form FrmParty. The DCount function
> checks for previous bookings and it works fine but why do I need such a
> long-winded syntax ie Forms![FrmParty].Form![FrmBookings]![EventDate] in the
> conditon part of the Dcount.
>
>
>
> Private Sub SessionCode_BeforeUpdate(Cancel As Integer)
>
>
>
> If DCount("[EventDate]", "TblBookings", "[EventDate] =
> Forms![FrmParty].Form![FrmBookings]![EventDate]") > 0 Then
>
> MsgBox ("Sorry this is already booked out!")
>
>
> End If
>
> End Sub
>
>
>
> How can I slim down this line? Me.[EventDate] does not work - why?
>
>
>
> Many thanks Geoff
>
>[/color]
Geoff, you didn't indicate where that code resides, but I'm guessing
that is in the FrmParty code module and SessionCode is a control on that
form. Assuming that to be the case, EventDate is a control on another
form. Yes, even though it is a subform of FrmParty, FrmBookings is a
different form. "Me." only points to the immediate form.
You could shorten it slightly to:
Me!FrmBookings.Form!EventDate
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember. |