473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1938
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

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

Similar topics

9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
1
by: xmp333 | last post by:
Hi, I have a form that is designed as a data sheet view. Attached to this is a subform with some VB code. When the user clicks on a row, the subform should pop up and run the VB code which...
1
by: Randy | last post by:
I have tried the code to attach a button to a form and use the help information on coding, but I can't seem to get it to work. I have a main form called MAIN CLIENT INFO2 There is a subform...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
5
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
5
by: christianlott1 | last post by:
I admit my form is pretty complex and may need a total overhaul - I have two subforms synchronized on a form through an unbound text box. When I enter a new record in the second subform it used...
1
by: asavu | last post by:
Hello, I'm somewhat new to this, and I definately need some help. I have a db for a small business, and I have a main form, Customer Info, which has a subform Appliance Info, which has a subform...
1
by: sparks | last post by:
I have a form/table with an autoid it is linked to a table/form with and ID as a 1 to many. Under this form/table I need another table with many records for each on of the many in the previous...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.