Results 1 to 7 of 7
  1. #1
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102

    Post Creating a Search form.

    Click image for larger version. 
<br /><script async src=
    Name: 1.png  Views: 22  Size: 8.6 KB  ID: 33544" class="thumbnail" style="float:CONFIG" />

    I got this "skeleton" to work with.
    There are text fields with search buttons, and combo boxes with limited options. A whole bunch of them, on top of a list. The list has 18 columns (maybe 17, but I need confirmation of something first).

    I want to make it so when I select something from the combo boxes, or write something in the text fields and then click their respective search button, the list refreshes with data matching that which was searched.

    I started investigating and got this:
    Code:
    Private Sub (ComboBoxName)_AfterUpdate()
        Me.(ListName).Requery
    End Sub
    But that doesn't quite work. It doesn't refresh the list.
    As for the Text Boxes:
    Code:
    Private Sub (ButtonName)_GotFocus()
        On Error Resume Next
        If IsNull(TextBoxName) Then
            MsgBox "Error message here", vbCritical, "Error"
            Me.(TextBoxName) = Empty
            Me.Recalc
        Else
            Me.Recalc
        End If
            Me.Recalc
    End Sub
    Same thing, not working.
    Last edited by TrulyVisceral; 04-13-2018 at 08:14 AM. Reason: Dunno

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724

  3. #3
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Quote Originally Posted by orange View Post
    Well, alright, that'll work, thanks.

    But the code I posted DOES work with a friend's DB, which is structured pretty much the same way (the search menu at least). So now am confuzzled.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    From post #1
    Same thing, not working.
    doesn't tell us much.
    In post #3 " now am confuzzled."

    Perhaps you could describe the requirement with some sample data.
    If/when you do test and get errors/unexpected result, I suggest you give more detail --perhaps even post a copy of the database with enough info to highlight the problem and instructions to replicate the issue.
    We really aren't interested in your database from an intellectual property perspective, just sufficient info to show the problem for the purpose of debugging/resolving/suggesting.....

  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    About the code:
    You have parentheses where they shouldn't be:
    Code:
    Private Sub (ComboBoxName)_AfterUpdate()
        Me.(ListName).Requery
    End Sub
    
    Private Sub (ButtonName)_GotFocus()   '<<-- GotFocus event??? Better would be the click event
        On Error Resume Next
        If IsNull(TextBoxName) Then  '<<-- I would use IsNull(Me.TextBoxName) since TextBoxName does not appear to be a variable
            MsgBox "Error message here", vbCritical, "Error"
            Me.(TextBoxName) = Empty
            Me.Recalc
        Else
            Me.Recalc
        End If
            Me.Recalc
    End Sub


    Maybe
    Code:
    Private Sub ComboBoxName_AfterUpdate()
        Me.ListName.Requery
    End Sub
    
    Private Sub ButtonName_Click()
        On Error Resume Next
        If NZ(Me.TextBoxName,"") = "" Then
            MsgBox "Error message here", vbCritical, "Error"
            Me.TextBoxName = Empty ' <<-- don't understand why this line is here. Me.TextBoxName is already NULL/Empty 
            Me.Recalc   ' <<-- not necessary because of the reclac after "END IF"
        Else
            Me.Recalc   ' <<-- not necessary because of the reclac after "END IF"
        End If
    
        Me.Recalc
    
    End Sub

  6. #6
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    I probably should have specified the parenthesis' were there just to emphasize the word. But alright.
    Also, I was away for a while, sorry for the late response.

  7. #7
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Quote Originally Posted by orange View Post
    From post #1 doesn't tell us much.
    In post #3 " now am confuzzled."

    Perhaps you could describe the requirement with some sample data.
    If/when you do test and get errors/unexpected result, I suggest you give more detail --perhaps even post a copy of the database with enough info to highlight the problem and instructions to replicate the issue.
    We really aren't interested in your database from an intellectual property perspective, just sufficient info to show the problem for the purpose of debugging/resolving/suggesting.....
    Hello, I'm back. Had to go away for a bit, sorry for that.
    Now, you wanted examples yes?
    This is from my friend's DB:
    Click image for larger version. 

Name:	1.png 
Views:	11 
Size:	36.2 KB 
ID:	33614
    And this is the code for the combo box:
    Code:
    Private Sub busq_incidete_por_AfterUpdate()
        Me.Lista69.Requery
    End Sub
    Click image for larger version. 

Name:	2.png 
Views:	11 
Size:	9.2 KB 
ID:	33615
    For the buttons:
    Code:
    Private Sub Btn_Buscar3_GotFocus()
        On Error Resume Next
        If IsNull(TxtBusqueda3) Then
            MsgBox "Ingrese un Dato a Buscar", vbCritical, "Error"
            Me.TxtBusqueda3 = Empty
            Me.Recalc
        Else
            Me.Recalc
        End If
            Me.Recalc
    End Sub
    The only difference between the different Combo Boxes's codes are their names, same for the buttons.
    Also, when I said "It doesn't work", what I mean is it literally does nothing, not even an error.

    EDIT: I JUST NOTICED SOMETHING.
    Apparently, in my friend's DB, the Combo Box's data origin is a Query, while mine are typed manually. I mean, the values aren't going to change, so I didn't have the need for a query. Does that change this or what?
    Click image for larger version. 

Name:	3.png 
Views:	10 
Size:	6.2 KB 
ID:	33616

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

Similar Threads

  1. Replies: 1
    Last Post: 11-30-2016, 03:41 AM
  2. Replies: 8
    Last Post: 09-02-2015, 03:00 PM
  3. Help creating a search form
    By ttn022191 in forum Sample Databases
    Replies: 5
    Last Post: 09-26-2014, 01:39 PM
  4. Need help in creating Search Form
    By bnar in forum Forms
    Replies: 2
    Last Post: 06-05-2012, 12:09 AM
  5. creating a search form
    By foxtet in forum Forms
    Replies: 4
    Last Post: 08-06-2011, 06:08 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