troubleshooting Question

Urgent, 500 points: Text box null issues

Avatar of rite_eh
rite_eh asked on
Microsoft Access
17 Comments1 Solution331 ViewsLast Modified:
Here is my code. I've tried several different things for referencing the text boxes on my form. (Isnull, len(textbox.text) > 0, etc.) When I use isnull(textBox) it reports null, even when there is text in the textbox. I am calling this changefilter routine from the OnChange properties of each textbox on the form.

Private Sub ChangeFilter()
    Dim strFilter As String
    On Error GoTo Err_ChangeFilter
   
    If Not Len(txtSerial) > 0 Then strFilter = strFilter & "[Serial] LIKE '" & Nz(txtSerial, "") & "*' AND"
    If Not Len(txtCustomer) > 0 Then strFilter = strFilter & "[Customer name] LIKE '" & Nz(txtCustomer, "") & "*' AND"
    If Not IsNull(Me.txtReport) Then strFilter = strFilter & "[Report customer name] LIKE '" & Nz(txtReport, "") & "*' AND"
    If Not IsNull(Me.txtAddress) Then strFilter = strFilter & "[Address] LIKE '" & Nz(txtAddress, "") & "*' AND"
    If Not IsNull(Me.txtCity) Then strFilter = strFilter & "[City] LIKE '" & Nz(txtCity, "") & "*' AND"
    If Not IsNull(Me.txtProvince) Then strFilter = strFilter & "[Province/State] LIKE '" & Nz(txtProvince, "") & "*' AND"
    If Not IsNull(Me.txtCountry) Then strFilter = strFilter & "[Country] LIKE '" & Nz(txtCountry, "") & "*' AND"
    If Not IsNull(Me.txtPostal) Then strFilter = strFilter & "[Postal/Zip code] LIKE '" & Nz(txtPostal, "") & "*' AND"
    If Not IsNull(Me.txtPhone) Then strFilter = strFilter & "[Main phone] LIKE '" & Nz(txtPhone, "") & "*' AND"
    If Not IsNull(Me.txtFax) Then strFilter = strFilter & "[Main fax] LIKE '" & Nz(txtFax, "") & "*' AND"
    If Not IsNull(Me.txtDID) Then strFilter = strFilter & "[DID] LIKE '" & Nz(txtDID, "") & "*' AND"
   
   
    If Right(strFilter, 3) = "AND" Then strFilter = Left(strFilter, Len(strFilter) - 4)
    Me.Customers_summary.Form.Filter = strFilter
    Me.Customers_summary.Form.FilterOn = True
   
Exit_ChangeFilter:
    Exit Sub

Err_ChangeFilter:
    MsgBox Err.Description
    Resume Exit_ChangeFilter
   
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 17 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros