By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

Open Single Record Reports from form using command button

P: 9
I have one tabbed form that links to a master table. One of these tabs links to a sub form (GRN, to GRN table) and another tab to another subform (SRN, to SRN table).

I can run a report that displays a single record of GRN+master form using

Expand|Select|Wrap|Line Numbers
  1. Private Sub Open_GRN_Click()
  2.  
  3. DoCmd.RunCommand acCmdSaveRecord
  4. DoCmd.OpenReport "GRN", acViewPreview, , "[SO Number] = " & [SO Number]
  5.  
  6. End Sub
However When I try to do the same for the SRN report, it shows one record but with empty fields. If I just run the report it shows all records with completed data.
This is what I have for the second report

Expand|Select|Wrap|Line Numbers
  1. Private Sub Open_SRN_Click()
  2.  
  3. DoCmd.RunCommand acCmdSaveRecord
  4. DoCmd.OpenReport "SRN", acViewPreview, , "[PO Number] = " & [PO Number]
  5.  
  6. End Sub

Do I need to adjust something on the code or is it something to do with the relationships?
Feb 26 '14 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,240
Are you sure [PO Number] is numeric? Do you have any code on the On NoData event of the report? It might be helpful to have a message box appear in that situation so you know the report ran but found nothing.

Jim
Feb 28 '14 #2

NeoPa
Expert Mod 15k+
P: 31,768
You don't say, but I expect [SO Number] is numeric whereas [PO Number] is alphanumeric (String).

If that is so then the code should use something like :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenReport("SRN', acViewPreview, , "[PO Number]='" & [PO Number] & "'"
See Quotes (') and Double-Quotes (") - Where and When to use them.
Mar 1 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.