Open subform that has the current record of calling form at opening


  1. Posts : 16
    Windows 7 Home Premium 64bit
       #1

    Open subform that has the current record of calling form at opening


    I though this would be simple but searches have not worked. here is my code from the caling form:

    Private Sub BD_stuff_Click()
    On Error GoTo Err_BD_stuff_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stLinkCriteria = CurrentRecord
    stDocName = "RFIsBD_stuff"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_BD_stuff_Click:
    Exit Sub
    Err_BD_stuff_Click:
    MsgBox Err.Description
    Resume Exit_BD_stuff_Click
    End Sub

    I thought defining the "stLinkCriteria" would work but it did not. I've tried severa other things from on line searches but nothing has worked the subform always is opened to the 1st record.
      My Computer


  2. Posts : 194
    Windows 10 x64
       #2

    I don't understand the context for this question. Searching this forum, from your hard drive, from an application?
      My Computer


  3. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #3

    Silvera said:
    I though this would be simple but searches have not worked. here is my code from the caling form:

    Private Sub BD_stuff_Click()
    On Error GoTo Err_BD_stuff_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stLinkCriteria = CurrentRecord
    stDocName = "RFIsBD_stuff"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_BD_stuff_Click:
    Exit Sub
    Err_BD_stuff_Click:
    MsgBox Err.Description
    Resume Exit_BD_stuff_Click
    End Sub

    I thought defining the "stLinkCriteria" would work but it did not. I've tried severa other things from on line searches but nothing has worked the subform always is opened to the 1st record.
    This is all about ms access isn't it? Line "Resume Exit_BD_stuff_Click" can be removed....totally useless.
    It's not a subform at all! It's just a new form you open from a routine (most liekly a button click). The problem is stLinkCriteria. What do you want to accomplish with: stLinkCriteria = CurrentRecord?
    CurrentRecord is a property of the form so should be programmed as Me.CurrentRecord. But what do you want to do with current record number?
      My Computer


  4. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #4
      My Computer


  5. Posts : 16
    Windows 7 Home Premium 64bit
    Thread Starter
       #5

    You are correct. I posted it on an access forum but did not get a response. Glad you knew what I was talking about. I have since realized that is was not a sub form but a supplemental [yes separate] form, I added new fields to track a new situation so I created this form to manipulate the new data. A friend also a part-time programer for his job we are both architects. He manages the firm and I the construction administration of project being built. He suggested I define stLinkCriteria, I probable misunderstood what he was telling.

    Yes I use a label as a button to call the new form. I want it to open at the same record as the one that is calling the new one. I've been self teaching myself data base programing since the mid 80' and do not do it enough to remember all I have learned. I will try it out later this afternoon to see if I can make it work. Thank you very much for responding to me cry for help!!!
      My Computer


  6. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #6

    What do you mean by saying "same record"? Has the record a primary key? Is recordsource on called form the same as calling form?
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:02.
Find Us