Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    What is this? It doesn't match your last post (#9)

  2. #17
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    If you are lost and confused, don't worry, that's allowed! Happens to everyone.

  3. #18
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Yes sorry, I went to bad over being a little tired out from pecking away at that.
    I isolated the problem to the SQL of the query that I use. I have the SQL of the button that activates the query working just fine. When I began alter the "AND" and "OR" relationships between criteria in the query (qry_contacts_WHO) I isolated the problem. I can confirm it is an "AND" problem. When I replaced all of the "AND"s with "OR", all my newly input records appeared in the query. However, using the "OR" made my search method useless as it now doesn't really allow my criteria to sieve through my contacts.

    Do you have any thoughts on a way to retain my search capabilities while keep the "OR" between criteria? I will re-post the SQL and bold the isolated problem makers.

    SELECT tblWHO.FarmerID, tblWHO.Phone1C1, tblWHO.Phone2C1, tblWHO.FarmName, tblWHO.FarmCivicAddress, tblWHO.FarmCommunity, tblWHO.FarmPostalCode, tblWHO.Province, tblWHO.Email, tblWHO.Website, tblWHO.Facebook, tblWHO.Notes, tblWHO.RR, tblWHO.VERIFIED, tblContacts.ContactID, tblContacts.FirstName1, tblContacts.LastName1, tblContacts.FarmerContactID
    FROM tblWHO LEFT JOIN tblContacts ON tblWHO.FarmerID = tblContacts.FarmerContactID
    WHERE (((tblWHO.FarmName) Like "*" & Nz(Forms!MainSearchForm!txtfarm,"") & "*") And ((tblWHO.FarmCivicAddress) Like "*" & Nz(Forms!MainSearchForm!txtaddress,"") & "*")) Or (((tblWHO.FarmCommunity) Like "*" & Nz(Forms!MainSearchForm!txtcommunity,"") & "*") And ((tblContacts.FirstName1) Like "*" & Nz(Forms!MainSearchForm!txtfirst,"") & "*")) OR (((tblContacts.LastName1) Like "*" & Nz(Forms!MainSearchForm!txtlast,"") & "*"));


    I found it odd that just those two were the problem makers, but through trials one at a time, that's what I determined

  4. #19
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I am still confused, it looks as tho we are back to post #1 and posts 6-10 have been thrown out. I am looking for the Debug.Print of the query that results from that piece of code.

  5. #20
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    I ran the sql that you assisted in helping me design with the debug.print, however I must be doing something wrong. I am not presented with the debug.print of the query

    The query still runs but the new records still are not appearing, here is the SQL I entered with your assistance.

    Private Sub Command223_Click()
    Dim qdf As QueryDef, strSQL As String
    Set qdf = CurrentDb.QueryDefs("qry_contacts_WHO")
    strSQL = "SELECT tbl_WHO.* From tbl_WHO WHERE (1=1)"
    If Not IsNull(Me.txtfirst) Then
    SQL = SQL & " and ([FirstName1]) like '*" & Me.txtfirst & "*')"
    End If
    If Not IsNull(Me.txtlast) Then
    SQL = SQL & " and ([LastName1]) like '*" & Me.txtlast & "*')"
    End If
    If Not IsNull(Me.txtfarm) Then
    SQL = SQL & " and ([FarmName]) like '*" & Me.txtfarm & "*')"
    End If
    If Not IsNull(Me.txtaddress) Then
    SQL = SQL & " and ([FarmCivicAddress]) like '*" & Me.txtaddress & "*')"
    End If
    If Not IsNull(Me.txtcommunity) Then
    SQL = SQL & " and ([FarmCommunity]) like '*" & Me.txtcommunity & "*')"
    End If
    Debug.Print


    Me.Requery


    End Sub

  6. #21
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You need to tell it what to print
    Debug.Print something.

    Before you do this, revisit post 10

  7. #22
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Okay some progress! I made the corrections after reviewing post 10. The attempted to get the debugger to run the query. I don't believe I made the correct assumption. I receive an invalid or unqualified reference from my attempt.

    Dim qdf As QueryDef, strSQL As String
    Set qdf = CurrentDb.QueryDefs("qry_contacts_WHO")
    strSQL = "SELECT tbl_WHO.* From tbl_WHO"
    If Not IsNull(Me.txtfirst) Then
    SQL = SQL & " and ([FirstName1]) like '*" & Me.txtfirst & "*')"
    End If
    If Not IsNull(Me.txtlast) Then
    SQL = SQL & " and ([LastName1]) like '*" & Me.txtlast & "*')"
    End If
    If Not IsNull(Me.txtfarm) Then
    SQL = SQL & " and ([FarmName]) like '*" & Me.txtfarm & "*')"
    End If
    If Not IsNull(Me.txtaddress) Then
    SQL = SQL & " and ([FarmCivicAddress]) like '*" & Me.txtaddress & "*')"
    End If
    If Not IsNull(Me.txtcommunity) Then
    SQL = SQL & " and ([FarmCommunity]) like '*" & Me.txtcommunity & "*')"
    End If
    Debug.Print .qry_contacts_WHO


    Me.Requery


    End Sub

  8. #23
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Don't come back here until you have followed the instructions in post 10

  9. #24
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Hi again,

    I felt like I was being a little annoying as I had literally no idea what was going on with the code. I didn't want to be of any more confusion to you or those following this thread, so I went out and scowered/tested until I FINALLY fixed this. It actually wasn't that hard, but I didn't understand the concept of what was going on with my database which made things confusing for me.

    long story short it was a null value issue.

    For those looking for the fix:

    Nz(your variant such at Forms!Form!txtbox, isnull(your variant such at Forms!Form!txtbox))

    why this was so hard for me to grasp, I dont know. Just another learning curve with this program. thank you for the patience once again aytee111

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 02-15-2017, 08:21 AM
  2. Replies: 1
    Last Post: 10-12-2015, 09:02 AM
  3. Newly added record Search
    By galadrwin in forum Access
    Replies: 2
    Last Post: 02-10-2015, 06:27 AM
  4. Replies: 9
    Last Post: 10-25-2014, 04:09 PM
  5. Replies: 5
    Last Post: 02-10-2014, 04:46 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