Hello again everyone, I've been doing mental gymnastics for a couple of days now and as always, look to you good people to help me out.
I have Contacts related to Bids (one to many on ContactID), which are related (one to many on BidID) to Job Dates, Bid Details, and Images. Bids, Job Dates, Bid Details are located in a tabbed subform under contacts. I have 3 key filter fields in Contacts statusfilter, bidderfilter and biddatefilter. I am attempting to filter records located in the subform (and also pull up the related contacts information). Bid.Status, Bid.Bidder, JobDates.BidDate.
I have tried all of the ideas in various forums, setting the recordsource, filter by form, etc. I am currently testing this:
I'm getting Runtime error 3163, field is too small to accept....Code:Private Sub Command197_Click() On Error Resume Next Dim sSql As String Dim sCriteria As String sCriteria = "WHERE 1=1 " 'This code is for a specific search where you will need to enter the exact string 'The source for this code can either be from a table or query If Me![statusfilter] <> "" Then sCriteria = sCriteria & " and status = """ & statusfilter & """" End If 'This code is for a Like search where can enter part of a string 'The source for this code can either be from a table or query If Me![bidderfilter] <> "" Then sCriteria = sCriteria & " AND bidder like """ & bidderfilter & "*""" End If If Me![biddatefilter] <> "" Then sCriteria = sCriteria & " AND biddate Like """ & biddatefilter & "*""" End If If Nz(DCount("*", "bid", Right(sCriteria, Len(sCriteria) - 14)), 0) > 0 Then sSql = "SELECT DISTINCTROW BID.*, Contacts.Order, Contacts.Zone, Contacts.FirstName, Contacts.LastName, Contacts.FullName, Contacts.[PreviousCustomer?], Contacts.ServiceText, Contacts.Address, Contacts.[Street Name], Contacts.City, Contacts.State, Contacts.Zip, Contacts.Phone, Contacts.Notes, Contacts.fulladdress, Contacts.emailaddress, Contacts.DoJobBy, Jobdates.CalledDate, Jobdates.BidDate, Jobdates.AcceptedDate " & sCriteria Debug.Print sSql Forms![contacts]![bidsheet].Form.recordsource = sSql Forms![contacts]![bidsheet].Form.Requery Else MsgBox "The search failed find any records" & vbCr & vbCr & _ "that matches your search criteria?", vbOKOnly + vbQuestion, "Search Record" End If End Sub
Throughout my trials with various methods, my subforms have completely disappeared, the wrong data is displayed, no data is displayed. At one point I had 2 criteria working (Status and Bidder) but not the Bid Date. But I digress, is what I'm trying to do actually possible?
Thank you in advance!
Gina


Reply With Quote
I have tried Allen's filter and am now trying it again:
