473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

22 New Member
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 1964
BradHodge
166 Recognized Expert New Member
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 Recognized Expert Specialist
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
Christina123
22 New Member
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 Recognized Expert Top Contributor
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=Fo rms![Order![OrderNumber]]"

To this:
StrLinkCriteria = "OrderNumber=Fo rms![Order]![OrderNumber]"
Aug 10 '07 #5
Christina123
22 New Member
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 Recognized Expert Top Contributor
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 = "OrderNumbe r = " & Forms![Order]![OrderNumber]
DoCmd.OpenRepor t strDocName, acViewPreview, lngLinkCriteria
End Sub
Aug 10 '07 #7
Christina123
22 New Member
Private Sub cmdOrder_Click( )
Dim strDocName As String
Dim lngLinkCriteria As Long
strDocName = "rptOrder"
lngLinkCriteria = "OrderNumbe r = " & Forms![Order]![OrderNumber]
DoCmd.OpenRepor t 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 Recognized Expert Top Contributor
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 = "OrderNumbe r= '" & Forms![Order]![OrderNumber] & "'"
DoCmd.OpenRepor t 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
3337
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 sub form (code in the AfterUpdate Event). Here's the issue. If the user deletes a subform record. The field on the main form shows null even if there is a value in the preceding subform record. What I'd like it to do is immediately refresh to
1
3733
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 accesses the record corresponding to the row clicked. To get this row, I tried using Me.Parent.Bookmark. Unfortunately, this gets the "Current Record" which is set via the navigation
1
3147
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 called Client Contacts. I want to print the current record using the ID field in the Client Contacts subform in a report. I want to print to a report called MAIN CLIENT INFO using the current record in the subform.
1
2700
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 new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source for the form is the Mailing List table (key is Alarm #). The record source for the subform is the...
5
2255
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 records displayed in the subform going along for the ride. The parent form's recordset has fields string integer COLORNAME CLASSSIZE and a few more that aren't relevant here.
20
10828
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 either an option button plus two text fields or a checkbox plus two text fields Am wanting to save the user entries into an underlying table. Tag property for each option button, check box or text field has the value of the key
5
6992
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 to complain about nulls and then about 'can't repeat an index'. To solve this I wrote code on the main form's subform enter event (I'm surprised I found it. I must have spent an hour trying to program the enter and exit events from the subform...
1
1668
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 Service Call Info... these three forms are linked, and I run into a problem when I try to search through records. I set up a different form where the user can select a customer, after which he can either push a button and using that customer's...
1
1608
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 table. form1 form2 form3 table1 table2 table3 autoid -1-------------@ ID -1-----------------@- ID2 of course it won't allow this so I put in a second ID
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.