Results 1 to 6 of 6
  1. #1
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56

    Link 2 forms

    Hi,



    I have a long survey that needs to run over 2 pages due to the number of questions. I have a 'page 2' button on the bottom of the first page that opens page 2 of the survey. On page 1 the user selected the Client (Episode ID) and a Survey ID (ILSID) is automatically created. When the user selects the 'page 2 button' the blank form that opens autofills the client ID, Date that was filled out on the first page (which is happening due to Default ) but I want it to also put in the same Survey ID from page 1. When Page 2 opens I see a 'New" appear in the ILSID field? I currently have the following code, yet it is instead creating the next record which is wrong. Do you know how to amend this code so it allows the ILSID to only fill out from what is currently on Form 1?

    Code:
    Option Compare Database
    Option Explicit
    Private Sub cmdOpenPage2_Click()
    On Error GoTo Err_cmdOpenPage2_Click    Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "frmILSAssessment2"
        
        stLinkCriteria = "[ILSID]=" & Me![ILSID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_cmdOpenPage2_Click:
        Exit Sub
    Err_cmdOpenPage2_Click:
        MsgBox Err.Description
        Resume Exit_cmdOpenPage2_Click
        
    End Sub
    Thanks in advance for your time and effort.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you saved the data from the first Form yet? I assume the 2nd Form is using the same table as the 1st Form.

  3. #3
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56
    I just presumed when I left the first form the data saved. I am actually using a query for Form 1 and a different query for form 2, although they are both using the same main table with linkages to the different survey groupings. There are about 10 groups of questions and each group has it's own table, all referring to the ILSID.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try adding these two lines of code and see if it makes a difference:
    Code:
    Option Compare Database
    Option Explicit
    Private Sub cmdOpenPage2_Click()
    On Error GoTo Err_cmdOpenPage2_Click    Dim stDocName As String
        Dim stDocName As String
        Dim stLinkCriteria As String
        If Me.Dirty Then Me.Dirty = False
    
        stDocName = "frmILSAssessment2"
        
        stLinkCriteria = "[ILSID]=" & Me![ILSID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_cmdOpenPage2_Click:
        Exit Sub
    Err_cmdOpenPage2_Click:
        MsgBox Err.Description
        Resume Exit_cmdOpenPage2_Click
        
    End Sub

  5. #5
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56
    Yeah it worked!. Thank you so much for your help!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Glad we could help.

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

Similar Threads

  1. Replies: 12
    Last Post: 10-20-2014, 11:22 AM
  2. Replies: 5
    Last Post: 03-15-2012, 09:46 AM
  3. ID Link issues between Forms/Tables
    By fat ralphy in forum Access
    Replies: 4
    Last Post: 10-13-2011, 03:20 PM
  4. Link two forms to display related data
    By KrisDdb in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 02:41 PM
  5. Link to Forms
    By Luke in forum Forms
    Replies: 1
    Last Post: 07-14-2011, 08:51 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