Connecting Tech Pros Worldwide Help | Site Map

Syntax in DCount function

  #1  
Old March 12th, 2006, 05:25 PM
Geoff
Guest
 
Posts: n/a
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


  #2  
Old March 12th, 2006, 06:15 PM
Randy Harris
Guest
 
Posts: n/a

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.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Dreaded DCOUNT Function in a Report bmyers answers 35 October 25th, 2007 09:04 PM
DCount groups in a report Wingz answers 2 November 17th, 2006 08:21 PM
Beginner's help using count/Dcount function Simon Matthews answers 1 November 12th, 2005 10:44 PM
Beginner's help using count/Dcount function Simon Matthews answers 1 November 12th, 2005 10:17 PM