Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    Richmond, VA
    Posts
    12

    Smile Unanswered: Here's an easy question!

    I am trying to pull out only records that have birthdays between such and such dates. I must be writing the expression all wrong. In the quiery under the Birthday field,under criteria I write: Between [7/01/2004] and [7/30/2004]

    When I run the query, not a single record appears!

    Thanks for helping me out!

    A newby,

    Julie

  2. #2
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Try:
    Between #7/01/2004# and #7/30/2004#
    Ryan
    My Blog

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Hi Julie,

    I had a similar situation and went about it a bit differently. I created an UnboundForm and placed to TextBoxes on it. One for BeginningDate and one EndingDate. Then, once both dates are entered I have a CommandButton that does all the work. Simply called OpenForm. The code behind it is this:

    Code:
    Private Sub cmdOpenForm_Click()
    On Error GoTo Err_cmdOpenForm_Click
    'This will pull every date between these dates, inclusive. Give it a whirl Julie.
    
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "frmDateGrabber"
        
        stLinkCriteria = "[PurchaseDate]>=" & "#" & Me![BeginningDate] & "# AND [PurchaseDate]<=" & "#" & Me![EndingDate] & "#"
    
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_cmdOpenForm_Click:
        Exit Sub
    
    Err_cmdOpenForm_Click:
        MsgBox Err.Description
        Resume Exit_cmdOpenForm_Click
        
    End Sub
    Also for the sake of making it easy to clear your entries if you change your mind I have this code behind the RESET button:

    Code:
    Private Sub Reset_Click()
    
        If Not IsNull(BeginningDate) And Not IsNull(EndingDate) Then
        
        [BeginningDate] = ""
        [EndingDate] = ""
        
        End If
    End Sub
    That's all there is to it. Let me know if you like it. This way you don't have to set parameters in your query and the fields for both dates are also Formatted. This way the user just types and the format (input mask) is automatic.

    have a nice one,
    Bud

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •