472,145 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Getting Current Form & Subform Info To Either Print Or Dump Into a Record

Currently working with Microsoft Office 2000 and whatever version of Access came with that.

I am developing a database to track the comings and goings of shared tools.
Everything works splendidly except I have printing issues, primarily I have no idea what I am doing.

I have a form that contains the date and the info of the person doing the ordering as well as a subform that has the serial number of the part, the description and storage location. The subform is set up as datasheet view so that multiple items can be ordered at once.

When the orderer clicks on the order button that closes the order form & subform and opens the home page. But I also need it to print off a list of what has been ordered (subform info) and the info of the person doing the order (form info).

I have tried using the print commands in the VB docmd. part but they do not seem to do what I require. I have tried to use the queries that the form and subform are running off of to make a report that will print, this had limited succes as it printed off everything that has ever been ordered. I tried making a new query with the criteria of the order date being =now() but that did nada.

Sooo...anyone have any suggestions to solve my quandry??
Aug 3 '07 #1
8 1812
BradHodge
166 Expert 100+
It sounds like you were headed in the right direction. I would make a report based on the queries that the form is based on. Then I would add this script to your Order Button...

Expand|Select|Wrap|Line Numbers
  1. Dim strDocName as String
  2. Dim strLinkCriteria as String
  3. strDocName= "YourReportName "
  4. strLinkCriteria="YourPrimaryKey =Forms![YourFormName ![YourPrimaryKey ]"
  5. DoCmd.OpenReport strDocName, acViewNormal,strLinkCriteria
This will open your new report with only the record containing the primary key that is showing on the form. You could change acViewNormal (above) to acViewPreview while you are playing with it. It will then do PrintPreview instead of printing out directly.

Hope this helps,

Brad.
Aug 4 '07 #2
missinglinq
3,532 Expert 2GB
In the future, please refrain from using all caps in your title or post! Online this is considered to be shouting makes reading the text difficult. Many members will simply ignore a poster who engages in this behavior.

Welcome to The Scripts!

Linq ;0)>
Aug 4 '07 #3
Well I did all of that. What happens now is it opens the report but is still showing what has been ordered. It is not recognizing the Link Criteria, that I only want the current form to print.
This is what I have on my button thus far (this is for OnClick):

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOrder_Click()
  2. Dim strDocName As String
  3. Dim StrLinkCriteria As String
  4. strDocName = "rptOrder"
  5. StrLinkCriteria = "OrderNumber=Forms![Order![OrderNumber]]"
  6. DoCmd.OpenReport strDocName, acViewPreview, StrLinkCriteria
  7. End Sub
So I don't quite know where to procced from here. I have tried using the primary key on my subform, but that made no changes.
Aug 10 '07 #4
puppydogbuddy
1,923 Expert 1GB
Well I did all of that. What happens now is it opens the report but is still showing what has been ordered. It is not recognizing the Link Criteria, that I only want the current form to print.
This is what I have on my button thus far (this is for OnClick):

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOrder_Click()
  2. Dim strDocName As String
  3. Dim StrLinkCriteria As String
  4. strDocName = "rptOrder"
  5. StrLinkCriteria = "OrderNumber=Forms![Order![OrderNumber]]"
  6. DoCmd.OpenReport strDocName, acViewPreview, StrLinkCriteria
  7. End Sub
So I don't quite know where to procced from here. I have tried using the primary key on my subform, but that made no changes.

You did not quite follow the syntax that Brad gave you for StrLInkCriteria. You have a missing right parenthese in one section of the string and an extra right parentheses at the end of the string. Also, the syntax of the string assumes that OrderNumber is a text data type. If OrderNumber is a numeric data type the syntax would have to be changed.

change this:
StrLinkCriteria = "OrderNumber=Forms![Order![OrderNumber]]"

To this:
StrLinkCriteria = "OrderNumber=Forms![Order]![OrderNumber]"
Aug 10 '07 #5
OrderNumber is an auto number as it is the primary key and serves no purpose other than to give a number to the order.

What would need to be changed since it is numeric data?
Aug 10 '07 #6
puppydogbuddy
1,923 Expert 1GB
OrderNumber is an auto number as it is the primary key and serves no purpose other than to give a number to the order.

What would need to be changed since it is numeric data?

Private Sub cmdOrder_Click()
Dim strDocName As String
Dim lngLinkCriteria As Long
strDocName = "rptOrder"
lngLinkCriteria = "OrderNumber = " & Forms![Order]![OrderNumber]
DoCmd.OpenReport strDocName, acViewPreview, lngLinkCriteria
End Sub
Aug 10 '07 #7
Private Sub cmdOrder_Click()
Dim strDocName As String
Dim lngLinkCriteria As Long
strDocName = "rptOrder"
lngLinkCriteria = "OrderNumber = " & Forms![Order]![OrderNumber]
DoCmd.OpenReport strDocName, acViewPreview, lngLinkCriteria
End Sub
Well that kind of worked, it now shows a report of all items that have been returned. Which makes no sense as returned and ordered have no direct relationships.

I am going to assume that I have made an error somewhere else in my database because the code should work.
Aug 10 '07 #8
puppydogbuddy
1,923 Expert 1GB
Well that kind of worked, it now shows a report of all items that have been returned. Which makes no sense as returned and ordered have no direct relationships.

I am going to assume that I have made an error somewhere else in my database because the code should work.
Try it this way as per the link below:

Private Sub cmdOrder_Click()
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "rptOrder"
strLinkCriteria = "OrderNumber= '" & Forms![Order]![OrderNumber] & "'"
DoCmd.OpenReport strDocName, acViewPreview, strLinkCriteria
End Sub

http://support.microsoft.com/kb/209560
Aug 10 '07 #9

Post your reply

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

Similar topics

9 posts views Thread by William Wisnieski | last post: by
1 post views Thread by Randy | last post: by
5 posts views Thread by Thelma Lubkin | last post: by
5 posts views Thread by christianlott1 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.