By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Syntax in DCount function

P: 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
Mar 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Geoff wrote:
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


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.
Mar 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.