Results 1 to 6 of 6
  1. #1
    coilerDH is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    13

    Help with modifying my code to work with a navigation form with sub forms

    I have a "search form" that is its own form. The search form has a combo box and a search button. I have a bit of code in the button that currently will take the value of the combo box, look up the primary key field and populate several other forms. So when I use the search, I will have several forms open and populate with the data(the forms share fname, lname, and an ID). Other than that the forms show different information.
    I would like to adapt this to work with a navigation form. I have created a navigation form, and added my client data forms to it. What I'm not sure about is how I need to modify the code. I have done extensive searching but I fail to make sense of how to adapt my code.
    Private Sub btnClientSearch_Click()
    Dim strSQL As String
    If Not Nz(cbxLastName) = "" Then strSQL = strSQL & " And [LastName]='" & cbxLastName & "'"


    strSQL = Mid(strSQL, 6)


    If strSQL = "" Then
    MsgBox "Please enter at least one criteria field.", vbExclamation
    Exit Sub
    End If


    Dim strID As String
    strID = Nz(DLookup("ID", "[Table1]", strSQL))
    If strID = "" Then
    MsgBox "No match!", vbExclamation
    Exit Sub
    End If


    FindClient "Form1", strID
    FindClient "Form2", strID


    FindClient "Form3", strID
    FindClient "Form4", strID


    End Sub




    Private Sub FindClient(strFormName, strID As String)
    DoCmd.OpenForm strFormName
    Dim rs As Recordset
    Set rs = Forms(strFormName).RecordsetClone
    rs.FindFirst "ID='" & strID & "'"
    If Not rs.NoMatch Then Forms(strFormName).Bookmark = rs.Bookmark


    End Sub
    I believe the changes need to be made in the FindClient method.
    Help or suggestions would be greatly appreciated. Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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
    coilerDH is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    13
    I have seen that in my previous searches. I am failing to see how to apply the solution there to my code.
    Like "*" & [Forms]![NavigationForm]![NavigationSubform]![FnameTxt] & "*"

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't like and don't use Navigation form/control.

    I have never tried to build a generic search procedure.

    As noted in the referenced link, Navigation form/control works different from normal forms. If I understand correctly, not all subforms are open at the same time, so calling the search against all 4 subforms at same time will not work, even if you can get the reference syntax correct.

    I don't understand why you need to do search against subforms anyway. Aren't they synchronized to the main form? Apply filter to main form.
    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
    coilerDH is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    13
    Yes they are synchronized to the main form. But the form that is used for search is not a part of that navigation form/subform group. I m tying to help someone out and modify their existing access database. I don't know much about access and haven't worked in VB for probably 10+ yrs. If it doesn't work, then Ill try something else. Like remove the search form. So I reached out to the community to see if the existing setup could be altered to work with a navigation form.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I think the issues with navigation form for what you want are identified. I don't think the approach is practical.
    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. Replies: 5
    Last Post: 09-05-2014, 12:59 PM
  2. Replies: 11
    Last Post: 12-11-2013, 10:35 AM
  3. Replies: 4
    Last Post: 07-22-2013, 10:46 AM
  4. Forms Navigation Bar on every form
    By dhogan444 in forum Forms
    Replies: 2
    Last Post: 12-03-2012, 06:19 PM
  5. Replies: 1
    Last Post: 03-24-2010, 02:25 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