Results 1 to 3 of 3
  1. #1
    Integrate is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    12

    Dcount to return total based on date field

    Hi, I think this should be a relatively easy macro but I just can't get it to work.


    When someone enters the date of a booking I want a message box, or warning to appear if there are already too many bookings for that date.
    I can't get the Dcount to work based on the text box. I have tried a few options, I managed to get it to recognise the text box I think, but then I would get another error.
    I then had a crash issue and lost the code. It was something like this:




    Code:
    Dim intCount As Integer
    intCount = DCount("[OrderNumber]", "[tblDelivery]", "[DelDate] = '" & Me.[DelDate].Value & "'")
    MsgBox "There are " & intCount & " bookings on this date."

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    If DelDate is of date data type I think it needs #. Perhaps something like:
    Code:
    intCount = DCount("[OrderNumber]", "[tblDelivery]", "[DelDate] = #" & Me.[DelDate] & "#")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Integrate is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    12
    Perfect. Thank you so much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2013, 03:14 PM
  2. Replies: 3
    Last Post: 04-01-2012, 01:40 PM
  3. Running Total Based on a Date in a field
    By scratchmb in forum Access
    Replies: 4
    Last Post: 02-15-2012, 05:31 PM
  4. Replies: 1
    Last Post: 03-01-2011, 04:03 PM
  5. Total based on Formula based on field value
    By cjbuechler in forum Reports
    Replies: 15
    Last Post: 07-10-2009, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums