Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003

    Question Unanswered: Filtering a form from a separate form

    Hi There,

    I've been racking my brains all day about his problem. I have 2 forms, one form (FormA) is bound to a record set and displays one record at a time. The second form (FormB) is opened by clicking a command button on formA and contains 3 fields. Based on what the user enters into those 3 fields I compile a filter string which I want to apply to FormA.

    I've tried the following in the code in FormB with no success:

    strCondition = "[DateTime] >= '" & Me.txtStart & "' And [DateTime] <= '" & Me.txtEnd & "'"

    If Not IsNothing(Me.cboCoach) Then
    strCondition = strCondition & " And [Responsibility] = '" & Me.cboCoach & "'"
    End If

    Forms("Input/Edit/Find SupCall-In").Filter = strCondition
    Forms("Input/Edit/Find SupCall-In").FilterOn = True

    This returns the error "You cancelled the previous operation"

    I've also tried many other ways of doing this, like calling a method in FormA from FormB and passing in the condition. Then using the Me.Filter command in FormA also returns the same error and setting the focus to formA and running 'DoCmd.Applyfilter , strCondition' returns this error "The ApplyFilter operation was cancelled".

    Any help appreciated, thanks

  2. #2
    Join Date
    Aug 2003

    Re: Filtering a form from a separate form

    If the [DateTime] field is of Date/Time type, you are using wrong delimiters. The single quote (') is for text data, while for Date/Time data you must use the pound character (#).

    strCondition = "[DateTime] >= #" & Me.txtStart & "# And [DateTime] <= #" & Me.txtEnd & "#"

    Or (a little shorter):

    strCondition = "[DateTime] Between #" & Me.txtStart & "# And #" & Me.txtEnd & "#"

    Depending on your local date format and date delimiter settings, you may need to first reformat data in the text fields, as Access accepts only the "mm/dd/yyyy" and "yyyy/mm/dd" formats and delimiters.

  3. #3
    Join Date
    Nov 2003
    Thanks a lot that worked perfectly.

Posting Permissions

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