473,396 Members | 1,865 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,396 software developers and data experts.

Display current records from Continuous form in Report

3
Hi, I have searched and tried a bunch of different ways for the past day to accomplish this goal.

I have a Continuous form(frmPayment) that is limited to two new records. The users will be inputting payment information on this form. The users will then have to print a receipt(rptReceipt) for the customer that displays their payment information. I created a select query(qryReceipt) that selects all of the receipts that were entered by the user but I can not figure out a way for the report to only display the record(s) from the form.

The reason this is difficult is because the user can create one or two new records and I only want the receipt to display the record(s) that were just processed.

Thanks for your help.
Apr 6 '16 #1

✓ answered by jforbes

I would use the WhereClause of the DoCmd.OpenReport to limit the report to only the Receipts that you wish to print. How to: Apply a Filter When Opening a Form or Report

The WhereClause (Condition) can be pretty much any SQL WhereClause for the RecordSource of your Report, so there are a few different ways you could provide this. The way I would go about this is to loop through the records on the Form and create a list of IDs to include in the WhereClause.

This is an example of using a RecordSet of an Employees Form and building a WhereClause of all the IDs, then opening a Report with just those IDs:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command9_Click()
  2.     Dim oRst As DAO.Recordset
  3.     Dim sWhere As String
  4.  
  5.     Set oRst = Me.RecordsetClone
  6.     oRst.MoveFirst
  7.     Do While Not oRst.EOF
  8.         sWhere = sWhere & " OR ID=" & oRst!ID
  9.         oRst.MoveNext
  10.     Loop
  11.     If Len(sWhere) > 0 Then sWhere = Right(sWhere, Len(sWhere) - 4)
  12.     Debug.Print sWhere
  13.     DoCmd.OpenReport "rptEmployees", , , sWhere
  14. End Sub

4 2487
PhilOfWalton
1,430 Expert 1GB
IMO your problem is far from clear, which may in part be the reason you have a problem.
Are you saying you have a main form Customers with a continuous subform for payments (the normal way of handling things) or a continuous form with a Combo Box to select a customer, and 2 payment fields for that customer record.
The "Just Processed" is another interesting concept.
It would help to know the structure of your tables.

Phil
Apr 6 '16 #2
Kizer
3
Thanks for the response Phil.
I am going to try my best to describe this. The main form (frmPayment)is a continuous form that is limited to only two new records. This form does not contain any subforms.
The requirement was to give the end users a screen where they could process up to two different payments for different customers on the same screen and to print a receipt displaying the payment information that the customer just made.
By "Just Processed" I am referring to the payment(s) that the customer just made.
I have separate tables for the Customer(tblPolicyholder), Policynumber (tblPolicynumber), PaymentAmount (tblPaymentAmount),PaymentType(tblPaymentType), Company (tblCompany) and two others for security and an audit trail.

I currently have two separate buttons in the form footer where the user can select either one, depending on if they accepted one payment or two. Since they have started using this database I have notice that some users are not clicking the correct button which has lead me to here.
Apr 6 '16 #3
jforbes
1,107 Expert 1GB
I would use the WhereClause of the DoCmd.OpenReport to limit the report to only the Receipts that you wish to print. How to: Apply a Filter When Opening a Form or Report

The WhereClause (Condition) can be pretty much any SQL WhereClause for the RecordSource of your Report, so there are a few different ways you could provide this. The way I would go about this is to loop through the records on the Form and create a list of IDs to include in the WhereClause.

This is an example of using a RecordSet of an Employees Form and building a WhereClause of all the IDs, then opening a Report with just those IDs:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command9_Click()
  2.     Dim oRst As DAO.Recordset
  3.     Dim sWhere As String
  4.  
  5.     Set oRst = Me.RecordsetClone
  6.     oRst.MoveFirst
  7.     Do While Not oRst.EOF
  8.         sWhere = sWhere & " OR ID=" & oRst!ID
  9.         oRst.MoveNext
  10.     Loop
  11.     If Len(sWhere) > 0 Then sWhere = Right(sWhere, Len(sWhere) - 4)
  12.     Debug.Print sWhere
  13.     DoCmd.OpenReport "rptEmployees", , , sWhere
  14. End Sub
Apr 6 '16 #4
PhilOfWalton
1,430 Expert 1GB
I'm going to be honest. As I understand it, you have a form on which you enter a payment, then select which customer the payment is to be set against. Presumably a customer may have more that one policy so somehow you also select the policy. What safeguards have you that the payment is set against an amount owed by this customer for this policy? Is there a field in the tblPolicyNumber that shows the amount owed? What happens with overpayments and underpayments?
Assuming your structure is right, and I would be far from happy with it, the safe way of dealing with your problem is to have a field in the PaymentAmount table called ReceiptPrinted (DefaultValue = False). Then at any stage you can run your report using the condition ReceiptPrinted = False and on the OnFormat of the detail of the report, run a bit of code to update the ReceiptPrinted = True.

Phil
Apr 6 '16 #5

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

Similar topics

3
by: Damian | last post by:
Hi. Is there a way to programatically populate a continuous form? I have an array of descriptions that I want to display in the continuous form and I have a textbox on the form called...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
2
by: marvin | last post by:
I would like a user to be able to click a button whilst viewing a record within a form and see the /same/ record in a report. By default Access shows the first record in the table because no query...
7
by: luanhoxung | last post by:
hi all!! i get small trouble in display a text box. My text box will be show a value string base on my combo box choice. But text box always get the same value when i choose a new value in combo...
3
by: trgpham | last post by:
Hi all, I have a question and really hoping you guys can help or point me to the right direction. MY SCENARIO: I need to design a screen which show up all the questionnaires and the users can...
7
by: ARC | last post by:
Hello all, What's the proper paper size setting if you want to do a receipt printer report, that's a continuous form? I don't really see an option for a continuous paper size. Thanks! Andy
2
by: didacticone | last post by:
hi, i was wondering if someone can help me, i have a form, with an unbound text box and a command button (code below) that searches through the underlying table and filters the results to show only...
2
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few...
3
by: ggftw | last post by:
Hi, I have 2 forms named frmProdSearchCat and frmProdSearchMaxPrice. They allow the user to search for several products based on the category and their budget respectively. I have a report named...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.