Results 1 to 7 of 7
  1. #1
    captgnvr is offline Advanced Beginner
    Windows 2K Access 97
    Join Date
    Sep 2009
    Posts
    44

    How to print particular record chosen in a main form which has sub-form?

    D/SIRS

    I have a main form where I get to see names of staff with [M_ID] as one of the prime key and with [job-code1].

    The sub-form is linked with job-code. (linking child field as job-code to link master field to job-code1.

    The code to a command button is asf:



    Dim strWhere As String

    strWhere = "[M_ID] = " & Me.[M_ID]
    DoCmd.OpenReport "R_CABIN", acViewPreview, , strWhere

    I get message asking for parameter [M_ID].

    But if I open the report it shows the record for the first person in the query.

    Can you pls tell me if this code will work to print the selected record from a form which has records filtered in a subform?

    brgds/captgnvr

  2. #2
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    If the command button is setup on your main form that has the field "[M_ID]" and it is also in your report where the field name is "[M_ID]" then everything is setup correctly. I would suggest double-checking that. Also, I'm assuming that "[M-ID]" is a numeric type field.

  3. #3
    captgnvr is offline Advanced Beginner
    Windows 2K Access 97
    Join Date
    Sep 2009
    Posts
    44
    D/Datagopherdan
    Thanks for the response and you are right on track. I do not have this field in report bcos I do not want it to be seen. Based on your guidance i will try and figure out. Wanted to inform you before u log off.

  4. #4
    captgnvr is offline Advanced Beginner
    Windows 2K Access 97
    Join Date
    Sep 2009
    Posts
    44
    D/Datagopherdan

    BINGO. It was a great help and it works now. I would consider it as an intricate point overlooked and thanks to your pointing out, the problem is resolved.

    May I ask you, if I want for say three more records how to go about it.

    Do I have to change it to multi select list box or can I use the present form itself?

  5. #5
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    Glad you got it working. It sounds like you need more than just printing the current record. If that being the case, I would suggest making a separate criteria form where as you said, you would have a multi-select list box, where they can choose which records will appear in the report.

    Also, you can set that ID field to not be visible in the report, so it will not be displayed when the report is previewed or printed.

  6. #6
    captgnvr is offline Advanced Beginner
    Windows 2K Access 97
    Join Date
    Sep 2009
    Posts
    44
    D/Dan
    I went thro ur blog and read ur offer to help the novices like me and also read about ur allegiance to this forum.

    Thanks for all that help and I am really enjoying the printing the current record bcos as and when staff join there must be their various jobs in emergencies. Once again thanks to ur troubleshoot, it was made possible and with this, this thread can be considered solved n closed.

    brgds/captgnvr

  7. #7
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    YW. These type of forums had provided me with invaluable help when I was first starting out, so I try to give some of that back. Good luck to you.

    Quote Originally Posted by captgnvr View Post
    D/Dan
    I went thro ur blog and read ur offer to help the novices like me and also read about ur allegiance to this forum.

    Thanks for all that help and I am really enjoying the printing the current record bcos as and when staff join there must be their various jobs in emergencies. Once again thanks to ur troubleshoot, it was made possible and with this, this thread can be considered solved n closed.

    brgds/captgnvr

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

Similar Threads

  1. Replies: 10
    Last Post: 11-23-2010, 10:16 PM
  2. Print a specific record report from a form
    By cynthiacorley in forum Reports
    Replies: 27
    Last Post: 02-08-2010, 06:34 AM
  3. Replies: 6
    Last Post: 01-13-2010, 02:41 PM
  4. move from Main form into sub form
    By miziri in forum Forms
    Replies: 2
    Last Post: 11-28-2009, 06:04 PM
  5. Sorting main-form from a sub-form
    By Zukster in forum Forms
    Replies: 11
    Last Post: 08-21-2009, 03:21 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