Page 3 of 3 FirstFirst 123
Results 31 to 40 of 40
  1. #31
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,957
    Quote Originally Posted by Gicu View Post
    Not really Dave, there are others here much, much better and because that, they are probably much busier in their professional life to give entire solutions; me on the other hand have lots of time on my hands....


    Cheers,
    A little modest there Vlad?
    You have helped me a good few times in the past myself.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  2. #32
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi Gicu
    I found a problem?
    If I just open the form frmSystemsCategoryData without going thru the other form
    it creates an error.
    Is there a way to open this form by itself and with or without the opening arguments? Not sure on this....

  3. #33
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Quote Originally Posted by Gicu View Post
    Not really Dave, there are others here much, much better and because that, they are probably much busier in their professional life to give entire solutions; me on the other hand have lots of time on my hands....
    Cheers,
    I dont know, I have seen a lot of mericles come from you just on my stuff!

  4. #34
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi Welshgasman,
    Thanks, I assure you that I spend at least 2 days working on a solution before I post something on here. I understand how he did it now that it works. I
    actually tried something with find first and such but didnt have the necessary skills to complete it correctly. I learned a lot from this
    little issue. I am a very visual person so some of these coding things i cant vision at all...
    Dave

  5. #35
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,957
    I am interested to see his approach tomorrow.
    I myself would have done it with linked forms, the Access way.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #36
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi Gicu
    I am able to make this work, been trying anyway
    Not sure of correct manor but it does work this way
    Here is what I added

    Code:
    Private Sub Form_Load()
    Dim lCatTypeID As Long
    Dim lCatID As Long
    Dim rs  As DAO.Recordset
    DoCmd.Echo False
    
    
    Me.txtSubCatID = Me.OpenArgs
    If Not IsNull(Me.OpenArgs) Then
    lCatID = DLookup("SystemCategoryID", "tblSystemCategorySub", "SystemCategorySubID=" & Me.OpenArgs)
    lCatTypeID = DLookup("SystemCategoryTypeID", "tblSystemCategory", "SystemCategoryID=" & lCatID)
    'now navigate to desired records
    'Type
    Set rs = Me.sfrmSystemCategoryType.Form.RecordsetClone
    rs.FindFirst "SystemCategoryTypeID=" & lCatTypeID
    Me.sfrmSystemCategoryType.Form.Bookmark = rs.Bookmark
    'Category
    Set rs = Me.sfrmSystemCategory.Form.RecordsetClone
    rs.FindFirst "SystemCategoryID=" & lCatID
    Me.sfrmSystemCategory.Form.Bookmark = rs.Bookmark
    'Subcategory
    Set rs = Me.sfrmSystemCategorySub.Form.RecordsetClone
    rs.FindFirst "SystemCategorySubID=" & Me.txtSubCatID
    Me.sfrmSystemCategorySub.Form.Bookmark = rs.Bookmark
    Else
    DoCmd.OpenForm "frmSystemCategoryData"
    End If
    DoCmd.Echo True
    End Sub

  7. #37
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,117
    The problem with linked (sub)forms is that you get limited subsets for each subsequent subform, so you're loosing the ability to see all records, so it depends on what you want to achieve in the end.
    @Dave: just add the new line at the top of the procedure to skip the rest if the ID was not provided:
    Code:
    Private Sub Form_Load()
    Dim lCatTypeID As Long
    Dim lCatID As Long
    Dim rs  As DAO.Recordset
    
    
    'Vlad - exit sub if form open on its own
    If IsNull(Me.txtSubCatID) Then Exit Sub
    
    
    DoCmd.Echo False
    Me.txtSubCatID = Me.OpenArgs
    
    
    lCatID = DLookup("SystemCategoryID", "tblSystemCategorySub", "SystemCategorySubID=" & Me.OpenArgs)
    lCatTypeID = DLookup("SystemCategoryTypeID", "tblSystemCategory", "SystemCategoryID=" & lCatID)
    'now navigate to desired records
    'Type
    Set rs = Me.sfrmSystemCategoryType.Form.RecordsetClone
    rs.FindFirst "SystemCategoryTypeID=" & lCatTypeID
    Me.sfrmSystemCategoryType.Form.Bookmark = rs.Bookmark
    'Category
    Set rs = Me.sfrmSystemCategory.Form.RecordsetClone
    rs.FindFirst "SystemCategoryID=" & lCatID
    Me.sfrmSystemCategory.Form.Bookmark = rs.Bookmark
    'Subcategory
    Set rs = Me.sfrmSystemCategorySub.Form.RecordsetClone
    rs.FindFirst "SystemCategorySubID=" & Me.txtSubCatID
    Me.sfrmSystemCategorySub.Form.Bookmark = rs.Bookmark
    DoCmd.Echo True
    End Sub
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #38
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,117
    Hi Dave,
    Almost, you got the right idea, but you're issuing the OpenForm again on the already opened form (it will not open it again so you're OK but just an "eye sore" ) ; you can remove that and the preceding Else lines and it should work fine.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #39
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Thanks so much,
    I learn so much from you!
    That is fantastic and works like a charm!
    Dave Marking this as solved!
    Again,
    Thank you all

  10. #40
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Quote Originally Posted by Gicu View Post
    The problem with linked (sub)forms is that you get limited subsets for each subsequent subform, so you're loosing the ability to see all records, so it depends on what you want to achieve in the end.
    @Dave: just add the new line at the top of the procedure to skip the rest if the ID was not provided:
    Code:
    
    
    'Vlad - exit sub if form open on its own
    If IsNull(Me.txtSubCatID) Then Exit Sub
    Cheers,
    Had to change this to OpenArgs but that was easy
    Thanks Again

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-30-2022, 01:34 AM
  2. Open form with specific record
    By Lukael in forum Programming
    Replies: 14
    Last Post: 11-16-2015, 06:31 AM
  3. 'SubTable' to manage items attached to a specific record
    By RichardGR in forum Database Design
    Replies: 4
    Last Post: 04-03-2013, 02:37 AM
  4. Open form on specific record
    By iky123 in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 09:56 AM
  5. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 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