Results 1 to 4 of 4
  1. #1
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    Need to add second criteria onto Form.Filter process by 9:30 AM. Need Quick Help

    Access 7007 and SQL Server 2008 R2.



    I have two Parent Forms on one screen, no Sub Forms. So they are not linked as Parent and Child. The First form applies a filter to the Second form. The First Form contains a field called "TaxYear". You double click the TaxYear field (running the code below) and it filters the second form so that the Second Form SPYDTaxYear = the First Form's TaxYear.

    The filter by SPYDTaxYear works fine. I need to quickly add a second criteria to the filter called, "PropertyID", an integer. So, on the First Form you double click on the TaxYear field and it should filter the Second Form by both SPYDTaxYear and PropertyID.

    Code:
    This filter by Tax Year works fine.
    
    Private Sub TaxYear_DblClick(Cancel As Integer)
    Dim stTaxYear As String 'From First Form
    stTaxYear = Me.TaxYear 'From First Form
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.FilterOn = False
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.Filter = "[SPYDTaxYear]= '" & stTaxYear & "'"
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.FilterOn = True
    
    The above filter works but it needs a second filter criteria of the PropertyID, an integer.
    
    My modification of the above filter after adding [PropertyID] errors out with a data type mismatch.
    
    Private Sub TaxYear_DblClick(Cancel As Integer)
    lngPropid = Me.PropertyID
    stTaxYear = Me.TaxYear
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.FilterOn = False
    
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.Filter = ("[SPYDTaxYear]= '" & stTaxYear & "' and "[Propertyid]= " & lngPropid &"')"
    
    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.FilterOn = True
    So the only thing I need is correct the filter so that it includes SPYDPropertyID which is an integer.
    I am prepping for a demo today at 10:00 AM. This is the last issue that is still not working correctly.
    I am continuing to work on this but I also posted this for additional help.

    Thanks Phred.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Give this a try
    = "[SPYDTaxYear]= '" & stTaxYear & "' AND [SPYDPropertyid]=" & lngPropid &

  3. #3
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246
    Hey, thanks. I got it fixed just when your message came in. Thank you so much.

    Forms![Frm_RecordstatusFrame]![Frm_SPYDTaxYears2].Form.Filter = "[PropertyID]= " & lngPropid & " AND [SPYDTaxYear] = '" & stTaxYear & "'"

    I am sure what I have can be improved but it meets my deadline at 10:00 AM.

    Your rapid response is so welcome. It's nice to have a backup.

    Phred

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Glad to hear.

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

Similar Threads

  1. Filter Query Criteria via Textbox in a form
    By r32chaos in forum Queries
    Replies: 3
    Last Post: 08-19-2014, 10:03 PM
  2. Replies: 3
    Last Post: 04-09-2014, 09:43 AM
  3. Multiple Form Filter Criteria vba code
    By Moonman in forum Programming
    Replies: 6
    Last Post: 11-16-2013, 12:42 AM
  4. Add 'filter by selection' to quick access
    By AndrewAfresh in forum Access
    Replies: 1
    Last Post: 11-18-2012, 04:01 PM
  5. Replies: 5
    Last Post: 04-11-2012, 06:52 PM

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