[AccessD] A2K: Can't Get DCount to work

Stephen Bond stephen at bondsoftware.co.nz
Tue May 11 23:58:15 CDT 2004


1.  Surround the date with the hash sign (#).
    so, "[OffenceDate] = #" & Me!txtOffenceDate) & "#"
2.  The other thing that comes to mind, and this 
    is off the top of my head, is that some expressions
    require dates to be in US format, so you may have
    to do this to Format(Me!txtOffenceDate),"mm/dd/yyyy")

    This might apply to SQL sattements only, can't remember

Stephen Bond
NZ 

> -----Original Message-----
> From: Darren DICK [mailto:d.dick at uws.edu.au]
> Sent: Wednesday, 12 May 2004 3:56 p.m.
> To: AccessD List
> Subject: [AccessD] A2K: Can't Get DCount to work
> 
> 
> Hello all
> Can anyone tell me what I am doing wrong here?
> I am trying to use dcount to determine how many occurrence of 
> a particular date appear in a table
> In my test table there are 8 records with the date 11/05/2004 
> So... In my code below,  Msgbox intX should show 8 but it 
> keeps showing 0 (Zero)
> 
> Dim intX As integer
> intX = DCount("[OffenceDate]", "tblOffences", "[OffenceDate] 
> = " & Me!txtOffenceDate)
> MsgBox intX
> 
> The table tblOffences is an existing table
> the field OffenceDate is an existing field Data 
> Type:Date/Time  formatted dd/mm/yyyy
> The control on my form txtOffenceDate is an existing control 
> (formatted dd/mm/yyyy)
> 
> I have checked spelling of field names many times and have 
> even copied and pasted
> the field names to guarantee spelling.
> 
> I have turned 'on and off' the formatting in various combinations.
> 
> Just can't get it to work
> 
> Any suggestions?
> 
> Many thanks
> 
> Darren
> 
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



More information about the AccessD mailing list