Results 1 to 4 of 4
  1. #1
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32

    Reference Form when using Navigation Form Access

    I have navigation form inside which i have Order By Customer form.


    i am trying to find order of Customer by OrderID for that i have using flowing code


    Code:
    Private Sub cmdSearch_Click()
    
        Dim search_customerID As Long
        search_customerID = DLookup("CustomerID", "Order", "OrderID =" & Me.txtSearch) 
        DoCmd.SearchForRecord acDataForm, "Order by Customer", acFirst, "CustomerID=" & search_customerID
    
    End Sub
    now i am geting error as shows in image.

    NOTE: When i am open "Order by Customer" form directly
    without inside navigation Form it works properly.
    but i am getting above error(shows in image) only when i open "Order by Customer" form using navigation form.


    Please guide me.
    Click image for larger version. 

Name:	Question.jpg 
Views:	14 
Size:	158.6 KB 
ID:	20490

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    inside a Navigation form, the Order by Customer form is a sub form; so this syntax is not valid:
    DoCmd.SearchForRecord acDataForm, "Order by Customer",

    because one must first reference the main form...... sorry I don't know the syntax for it as it is not a method I use plus I don't use Navigation forms...

    in general the approach I would take is for the Order by Customer form to be a standard inset sub form - whereby when making it the wizard will prompt & suggest for you to set up a linking key field between main form and sub form....then when you change customers in the main form - it triggers a requery of the sub form - and it would display only records of that customer. I would say this is a more classic design.

    the Navigation form, invented by Microsoft, is suppose to have an advantage in that it doesn't call data in a sub form located in a tab - until that tab button is pressed. And that can be helpful when one has many tabs and the sub forms contain lots of records.....but when that is not the case it really isn't the type of form to use - in my opinion alone.....

  3. #3
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32

  4. #4
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32
    Downlaod Project With Solution

    Code:
    PrivateSub cmdSearch_Click()
    
        Dim MainFK AsLong
        Dim rs As DAO.Recordset
        Dim WhereStr AsString
    
        MainFK = DLookup("MainformID","Subform","SubformID ="&Me.txtSearch)
    
        WhereStr ="MainformID="& MainFK
    
        WithMe.Form
    
            Set rs =.RecordsetClone
            rs.FindFirst WhereStr
    
            If _
                rs.NoMatch _
            Then
    
                MsgBox "Subform record not match to mainform record"
    
            Else
    
                .Bookmark = rs.Bookmark
    
            EndIf
    
        EndWith
    
    EndSub

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

Similar Threads

  1. Replies: 12
    Last Post: 10-23-2014, 02:08 AM
  2. Reference Subform on Navigation Form
    By GOP in forum Forms
    Replies: 1
    Last Post: 07-30-2014, 08:18 AM
  3. Replies: 3
    Last Post: 09-06-2012, 09:50 AM
  4. Subform Reference on Navigation Form
    By rts in forum Forms
    Replies: 1
    Last Post: 06-05-2012, 02:05 PM
  5. How to reference a form in the Navigation Form
    By HarryScofs in forum Access
    Replies: 3
    Last Post: 08-18-2011, 04:46 PM

Tags for this Thread

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