Results 1 to 11 of 11
  1. #1
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188

    New records not showing in form

    I have a problem I can't seem to figure out. I have a form with a bunch of search filters to help users find records. They can also create new records. The underlying query shows all records created but the form doesn't show any of the new records we add regardless of clearing all filters. I checked and it's updatable. I have tried all the things that are obvious to me but what could be some reasons this is happening?

  2. #2
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    563
    Quote Originally Posted by matey56 View Post
    I have a problem I can't seem to figure out. I have a form with a bunch of search filters to help users find records. They can also create new records. The underlying query shows all records created but the form doesn't show any of the new records we add regardless of clearing all filters. I checked and it's updatable. I have tried all the things that are obvious to me but what could be some reasons this is happening?
    If you open a form in Data Entry mode, you can't see the existing records. That's by design.

  3. #3
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188
    Quote Originally Posted by madpiet View Post
    If you open a form in Data Entry mode, you can't see the existing records. That's by design.
    It's not in data entry mode when it's opened. I have a button for users to add records via the GoToRecord - New macro. Could this be the problem?

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Have you tried refreshing or requerying the form after the new records are added?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188
    Quote Originally Posted by moke123 View Post
    Have you tried refreshing or requerying the form after the new records are added?
    Okay I found the reason. I just don't know how to fix it. I have four fields at the top of the form where users can filter records based on the data in the below fields. The problem is, if any of those four fields are blank the record doesn't show in the form. What can I do to my code to allow it to show records if any of the fields are blank?

    Code:
    Me.Filter = "[Number] like '*" & FIND & "*'" & " AND [Region] like '" & FIND2 & "*'" & " AND [Status] like '*" & FIND3 & "*'" & " AND [Location] like '*" & FIND4 & "*'"

  6. #6
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    563
    Quote Originally Posted by matey56 View Post
    Okay I found the reason. I just don't know how to fix it. I have four fields at the top of the form where users can filter records based on the data in the below fields. The problem is, if any of those four fields are blank the record doesn't show in the form. What can I do to my code to allow it to show records if any of the fields are blank?

    Code:
    Me.Filter = "[Number] like '*" & FIND & "*'" & " AND [Region] like '" & FIND2 & "*'" & " AND [Status] like '*" & FIND3 & "*'" & " AND [Location] like '*" & FIND4 & "*'"
    Add another button that turns off the filtering?

  7. #7
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188
    Quote Originally Posted by madpiet View Post
    Add another button that turns off the filtering?
    I do have a Clear button with the code below. The records with blank fields still don't show after I run the event.

    Code:
    Private Sub btnClearAll_Click()Me.FIND.SetFocus
    Me.FIND = ""
    Me.FIND2.SetFocus
    Me.FIND2 = ""
    Me.FIND3.SetFocus
    Me.FIND3 = ""
    Me.FIND4.SetFocus
    Me.FIND4 = ""
    Me.FilterOn = False
    Me.Requery
    End Sub

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    By "four fields at the top of the form", do you actually mean "four unbound controls"?

    Provide an alternate value for record field when it is Null. Since all 4 fields are string type, use an empty string. "Nz([Number],'') Like
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    430
    ' What can I do to my code to allow it to show records if any of the fields are blank?
    ' try evaluating each filters
    Code:
    Dim strFilter As String
    If Not IsNull(Me!Find) Then
        strFilter = strFilter & " And [Number] Like '*" & Me!Find & "*'"
    End If
    If Not IsNull(Me!Find2) Then
        strFilter = strFilter & " And [Region] Like '*" & Me!Find2 & "*'"
    End If
    If Not IsNull(Me!Find3) Then
        strFilter = strFilter & " And [Status] Like '*" & Me!Find3 & "*'"
    End If
    If Not IsNull(Me!Find4) Then
        strFilter = strFilter & " And [Location] Like '*" & Me!Find & "*'"
    End If
    If Len(strFilter) <> 0 Then
        strFilter = Mid$(strFilter, 5)
        Me.Filter = strFilter
        Me.FilterOn = True
    Else
        Me.FilterOn = False
    End If
    you can simplify code in clear button:
    Code:
    Private Sub btnClearAll_Click()
    Me.Find = Null
    Me.Find2 = Null
    Me.Find3 = Null
    Me.Find4 = Null
    Me.FilterOn = False
    Me.Requery
    End Sub

  10. #10
    Join Date
    Sep 2025
    Location
    Newport, Shropshire, UK
    Posts
    16
    Quote Originally Posted by matey56 View Post
    Okay I found the reason. I just don't know how to fix it. I have four fields at the top of the form where users can filter records based on the data in the below fields. The problem is, if any of those four fields are blank the record doesn't show in the form. What can I do to my code to allow it to show records if any of the fields are blank?

    Code:
    Me.Filter = "[Number] like '*" & FIND & "*'" & " AND [Region] like '" & FIND2 & "*'" & " AND [Status] like '*" & FIND3 & "*'" & " AND [Location] like '*" & FIND4 & "*'"
    Calling the LIKE operator with wildcards is unreliable as it does not allow for Nulls at the column positions. A reliable way is to use a query like the following as the form's RecordSource property:

    Code:
    SELECT *
    FROM [TableNameGoesHere]
    WHERE ([Number] = (Forms![FormNameGoesHere]![Find]
         OR Forms![FormNameGoesHere]![Find] IS NULL)
    AND ([Region] = (Forms![FormNameGoesHere]![Find2]
         OR Forms![FormNameGoesHere]![Find2] IS NULL)
    AND ([Status] = (Forms![FormNameGoesHere]![Find3]
         OR Forms![FormNameGoesHere]![Find3] IS NULL)
    AND ([Location] = (Forms![FormNameGoesHere]![Find4]
         OR Forms![FormNameGoesHere]![Find4] IS NULL);
    In each unbound control's AfterUpdate event procedure requery the form with:

    Code:
    Me.Requery
    Rather than using text boxes to enter the parameters, however, using combo boxes which return distinct values will ensure that only values in the table can be selected, e.g a combo box with a RowSource property of:

    Code:
    SELECT DISTINCT Region
    FROM [NameOfTableGoesHere]
    ORDER BY Region;
    will ensure that only valid region names can be entered or selected.

  11. #11
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    188
    Quote Originally Posted by Ken Sheridan View Post
    Calling the LIKE operator with wildcards is unreliable as it does not allow for Nulls at the column positions. A reliable way is to use a query like the following as the form's RecordSource property:

    Code:
    SELECT *
    FROM [TableNameGoesHere]
    WHERE ([Number] = (Forms![FormNameGoesHere]![Find]
         OR Forms![FormNameGoesHere]![Find] IS NULL)
    AND ([Region] = (Forms![FormNameGoesHere]![Find2]
         OR Forms![FormNameGoesHere]![Find2] IS NULL)
    AND ([Status] = (Forms![FormNameGoesHere]![Find3]
         OR Forms![FormNameGoesHere]![Find3] IS NULL)
    AND ([Location] = (Forms![FormNameGoesHere]![Find4]
         OR Forms![FormNameGoesHere]![Find4] IS NULL);
    In each unbound control's AfterUpdate event procedure requery the form with:

    Code:
    Me.Requery
    Rather than using text boxes to enter the parameters, however, using combo boxes which return distinct values will ensure that only values in the table can be selected, e.g a combo box with a RowSource property of:

    Code:
    SELECT DISTINCT Region
    FROM [NameOfTableGoesHere]
    ORDER BY Region;
    will ensure that only valid region names can be entered or selected.

    Thank you!

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

Similar Threads

  1. Replies: 9
    Last Post: 08-08-2016, 02:57 PM
  2. Replies: 3
    Last Post: 07-01-2015, 08:49 AM
  3. Replies: 15
    Last Post: 04-16-2014, 01:15 PM
  4. Replies: 6
    Last Post: 04-02-2014, 11:35 AM
  5. Replies: 5
    Last Post: 10-27-2011, 10:25 AM

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