Connecting Tech Pros Worldwide Help | Site Map

Syntax in DCount function

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 12th, 2006, 04:25 PM
Geoff
Guest
 
Posts: n/a
Default Syntax in DCount function

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, 05:15 PM
Randy Harris
Guest
 
Posts: n/a
Default 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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.