Results 1 to 6 of 6
  1. #1
    Sleepymum is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    14

    Linking forms (I think!!!)

    Hi Folks,
    Hope someone can give me a bit of advise.

    I have set up database and use a form for data entry.
    When the form is complete and record saved, I would like to be able to print out a form that has some of the fields in the data entry form. How can I get them to link, that it only prints the form for the record displayed on the data entry form.

    Hope someone can make sense of that and offer some advise.



    Thanks!"

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Here is a code that I have used in the past
    Code:
    Private Sub Command28_Click()
    On Error GoTo Err_Command28_Click
    
        Dim stDocName As String
    
        stDocName = "Submission"
        'DoCmd.OpenReport stDocName, acNormal, , "[ID] = Forms!frmClients!ID"
        DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=Forms!frmClients!ID"
    
    Exit_Command28_Click:
        Exit Sub
    
    Err_Command28_Click:
        MsgBox Err.Description
        Resume Exit_Command28_Click
        
    End Sub
    You will have to change your form names. The key here is the field name [ID] is the record number in the table and form that you are looking at. This was put onto a command button. The report used a query for a record source. The two DoCmd lines are in case you wish to view the report in a preview format or in normal format. The apostrophe in front turns the code to information text and does not execute it. Take your pick.

    HTH
    Alan

  3. #3
    Sleepymum is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    14
    Hi,

    Thanks for the reply.

    I have tried this and I am being asked to enter parameters?
    When I do this it opens a record but not the correct one!

    My Command is called OPEN
    My ID is NCMR ID
    My data entry form is called NCMRDataEntry
    and the form I want to open is call Non-Conforming Material Report

    so this is what I am using:

    Private Sub OPEN_Click()
    On Error GoTo Err_OPEN_Click
    Dim stDocName As String
    stDocName = "NCMRDataEntry"
    DoCmd.OpenForm stDocName, acNormal, , "[NCMR_ID] = Forms!frmNon-Conforming_Material_Report!NCMR_ID"

    Exit_OPEN_Click:
    Exit Sub
    Err_OPEN_Click:
    MsgBox Err.Description
    Resume Exit_OPEN_Click
    End Sub


    What am I doing wrong!

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Firstly; you are getting a parameter request because Access does not recognize a field name in your query. It is usually caused because you have a spelling error and the named field in the query is misspelled or does not exist in the table referenced or as an alias in the query. I would solve this first and make sure the query is working properly.

    You have set your DoCmd to open the form. The code I presented is for a report and not a form. It uses the form as the basis or information that you will generate in the report. Suggest you try to create a report based upon a query. Put the event on a command button on your form. With the form open to the record you want to have a report it will execute.

    Alan

  5. #5
    Access_Blaster is offline User
    Windows XP Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Quote Originally Posted by Sleepymum View Post
    Hi Folks,
    Hope someone can give me a bit of advise.

    I have set up database and use a form for data entry.
    When the form is complete and record saved, I would like to be able to print out a form that has some of the fields in the data entry form. How can I get them to link, that it only prints the form for the record displayed on the data entry form.

    Hope someone can make sense of that and offer some advise.

    Thanks!"
    Hi Sleepymum,
    Have a look here >> http://allenbrowne.com/casu-15.html I think your mixing Forms with Reports.

    Richard
    Last edited by Access_Blaster; 02-19-2011 at 07:57 PM.

  6. #6
    Sleepymum is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    14
    Thanks a million for all your all help.
    To get what I wanted I used the following code:
    Thanks for your help!!!

    Private Sub VIEW_NCMR_Click()
    On Error GoTo Err_VIEW_NCMR_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Non-Conforming Material Report"

    stLinkCriteria = "[NCMR ID]=" & "'" & Me![NCMR ID] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_VIEW_NCMR_Click:
    Exit Sub
    Err_VIEW_NCMR_Click:
    MsgBox Err.Description
    Resume Exit_VIEW_NCMR_Click

    End Sub

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

Similar Threads

  1. Linking Forms
    By glasgowlad1999 in forum Forms
    Replies: 1
    Last Post: 02-02-2011, 09:35 AM
  2. Linking two forms together
    By Lxmanager in forum Access
    Replies: 8
    Last Post: 09-27-2010, 05:10 PM
  3. Linking Forms
    By dalton in forum Forms
    Replies: 1
    Last Post: 05-30-2010, 11:23 PM
  4. linking forms by ID - automatically add ID
    By jlcaviglia-harris in forum Forms
    Replies: 0
    Last Post: 04-17-2009, 03:51 PM
  5. Linking tables and forms
    By vgatell in forum Access
    Replies: 0
    Last Post: 02-10-2007, 01:37 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