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

    FindRecord Problem

    Dear All,

    I attached a simple file which contains two forms.

    FRM1 has a sub form on it. In which field the user wants to do a search, the focus goes there (He/She selects the field). When the search button is clicked another form is opened and asks for the search item.



    So far I managed to identify the name of the form and the last control. Then I need to use FindRecord function to find the search item.


    I get error !

    Can somebody tell me what is wrong?

    Thanks
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Instead of a form/subform, why not a single form set in Continuous view? The search controls can be in that form header. Controls can be arranged to look like datasheet.

    You have a dynamic parameterized SQL as the Customer form RecordSource. The only code that should be needed is to requery the form. This would be easy if the search textbox was on frm1 instead of opening a popup for the criteria input.

    If you want to use VBA to manage the filter, then remove the dynamic parameters. The code approach you are taking is very tricky to accomplish.
    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.

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

    I know some other ways to do the search and I did.

    For some reasons I need to do it this way.

    Any help on FindRecord part?

    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Not if the query has dynamic parameters.
    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.

  5. #5
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    Dear June7,

    I attached a file which I did it on the form. You can see that it works when it is done from the same form, but when other form opens to get the search item I have a problem.

    Any ideas?
    Thanks
    Attached Files Attached Files

  6. #6
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    An interesting thing I just realized !!!!!!!!!!!!!!!!

    When I put a toggle break-point before FindRecord line, program stops and when I press F5 it finds the records without any error????????!!

    Anybody knows why!!!!!!

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The form RecordSource is still a dynamic parameterized query. But it references something named fld_search as parameter. What is fld_search? Why not reference Text10 which is name of textbox on Frm1?

    I always name subform container control different from the object it holds, like: ctrDetails

    Then the only code needed to filter the records is:

    Private Sub Command3_Click()
    Me.ctrDetails.Requery
    End Sub

    The Find First and Find Next is more complicated. I give up trying to make it work with form/subform.
    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.

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

  9. #9
    zareh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    29
    fld_search was added by somebody else, I forgot to delete it.
    Attached Files Attached Files

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    A couple of things about your database.

    You will save yourself hours of frustration with syntax errors IF:
    -you do not allow embedded spaces in your table fields and object names,
    -use only A thru Z and 0 thru 9 and _ (the underscore) in names.

    In your table you have duplicate names. This is a poor design.

    A database with 1 table is rare. WHAT is your proposed database about? A simple description would be helpful to readers.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Latest db doesn't incorporate my suggestions. I still give up.
    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.

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

Similar Threads

  1. FindRecord Crash if criteria not found
    By quicova in forum Programming
    Replies: 4
    Last Post: 09-13-2013, 08:42 AM
  2. can not use FindRecord with string
    By john60 in forum Programming
    Replies: 2
    Last Post: 08-10-2013, 08:25 AM
  3. Filter or FindRecord in Split Form
    By P5C768 in forum Forms
    Replies: 4
    Last Post: 03-20-2012, 12:16 PM
  4. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  5. Can you use a parameter in findrecord?
    By P5C768 in forum Programming
    Replies: 2
    Last Post: 08-20-2009, 04:36 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