Results 1 to 9 of 9
  1. #1
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29

    Creating Access "Find" window

    Dear All,



    Anybody knows how to create a form which does the same thing as "Find" window on access?

    "Find" Window gets the search item from the user and searches in the field in which the focus is (on the open form).

    I really need to do this , any help will be appreciated.

    I posted the same thing in other forums but seems nobody knows how to do it. I hope in this forum somebody knows (and of course tells!!)

    Many thanks

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Is there a reason you don't want to use the 'like' function in a query to find a specific string? then display the more limited dataset?

  3. #3
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    Thanks for the reply.

    I have 12 forms and in each form I have at least one sub-form which shows the data.
    I need to have a search form which can be called from every one of the forms. The user enters the search item in a text box and when "Search" button is clicked , the program should find the item in the open form.
    The search form can be opened from each of 12 forms. NOW in the search form how can I know from which form The search form is called i.e. how can I know the name of the form and the last control name which the user wants to search in?
    If I can identify these then I can use findrecord to find the searched item.
    I hope this is clear and someone can help me.
    Cheers

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if your database only has one form open at a time (that contains data) you can find out which ones are open then apply criteria or filters to the data on those forms but I would be curious about the design of your database that you need a 'universal' find function. I don't think I've ever seen a situation where something like that would be needed.

    here's some code to detect which forms are open in FORM VIEW

    Code:
        Dim obj As AccessObject
        Dim dbs As Object
        Dim sString As String
        
        Set dbs = Application.CurrentProject
        ' Search for open AccessObject objects in AllForms collection.
        For Each obj In dbs.AllForms
            If obj.IsLoaded = True Then
                If obj.CurrentView = 1 Then
                    ' Print name of obj.
                    Debug.Print obj.Name
                    sString = sString & obj.Name & "    " & obj.CurrentView & vbCrLf
                End If
            End If
        Next obj
        
        If Len(sString) > 0 Then
            MsgBox "THESE FORMS ARE OPEN " & vbCrLf & sString
        End If

  5. #5
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    Thanks for the tip.

    I need to create exactly the same process as the "Find" window does in the Access. It can find anything , anywhere the user wants.

    Any idea HOW?

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Having no idea what your database looks like it would be hard to give you direction.

    You asked
    NOW in the search form how can I know from which form The search form is called
    the code I gave you can do that, assuming you only have one form open at a time, in order to find out which control you were on before you went to the search form you'd likely have to track that through a non visible field on your previous form, but frankly, you are going about this the wrong way. If you want to pursue it your way you will have to find a way to track the most recent control (that was actually a text, combo box, list box or checkbox depending on your form) before your button click that goes to your search form.

    You would be far better served by providing a search function on each of your forms individually (it's far easier as well) that would search particular fields or a series of fields depending on your criteria. What you're proposing is needlessly complex especially if you are not versed in VBA and can't adapt the code I've given you to cycle through open forms.

  7. #7
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    Thanks for the reply.

    Please have a look at the attached file.

    When on the frm1.form the search button is clicked, form search opens and gets the search item. When search button (on this form) is pressed , it should find the item on the sub-form where the focus is.

    I have an accounting program which is written in Access 2003 and it does the same thing but it is locked and I can not see the code.

    Thanks again.
    Attached Files Attached Files

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    My-Search-Modified.zip

    Quicker, easier (both for the programmer and the user) way to perform this search function, example enclosed.

  9. #9
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    thanks a lot.

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

Similar Threads

  1. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  2. Replies: 0
    Last Post: 12-06-2011, 11:01 AM
  3. Replies: 3
    Last Post: 02-23-2010, 06:32 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