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

form details in a report

20
Hello,

What im trying to do is to create a report from a form. I have made a template for the report i would like to use.

What i have is a form which contains details of a customer. What i would like to do is when on a certain customer to be able to view their details that are shown on the form to appear on a report which can be printed off.

What is the best way to be able to do this?
Jul 31 '07 #1
3 1193
JKing
1,206 Expert 1GB
Hi, there. I'll try to explain the basics of what you need to do.

First off you should have a query that youre basing your report off. This query should contain all the customer info you need. Something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT customerID, customerFirstName, customerLastName, customerPhone, customerAddress, customerCity, customerProvince, customerPostalCode
  2. FROM tblCustomer
  3.  
Once you have your report created add a command button to your form. Under the onclick event of your command button you'll add code similar to this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPreview_Click()
  2.  
  3. Dim strLinkCriteria As String
  4. Dim strDoc As String
  5.  
  6. strLinkCriteria = "[CustomerID] = " & Me.CustomerID
  7. strDoc = "rptCustomerDetails"
  8.  
  9. DoCmd.OpenReport strDoc, acViewPreview, , strLinkCriteria, acWindowNormal
  10.  
  11. End Sub
  12.  
Notes:
  • strLinkCriteria is a string we build to act as the where statement of the report
  • strDoc is the report we want to open
  • Docmd.OpenReport is the command used to open the report with our specified parameters
  • if CustomerID is a text field rather than a number use this:
    Expand|Select|Wrap|Line Numbers
    1. strLinkCriteria = "[CustomerID] = '" & Me.CustomerID & "'"
    2.  

Give this a try and if you need any help or clarification I'd be more than happy to assist.

Jking
Jul 31 '07 #2
aman909
20
Hi, there. I'll try to explain the basics of what you need to do.

First off you should have a query that youre basing your report off. This query should contain all the customer info you need. Something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT customerID, customerFirstName, customerLastName, customerPhone, customerAddress, customerCity, customerProvince, customerPostalCode
  2. FROM tblCustomer
  3.  
Once you have your report created add a command button to your form. Under the onclick event of your command button you'll add code similar to this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPreview_Click()
  2.  
  3. Dim strLinkCriteria As String
  4. Dim strDoc As String
  5.  
  6. strLinkCriteria = "[CustomerID] = " & Me.CustomerID
  7. strDoc = "rptCustomerDetails"
  8.  
  9. DoCmd.OpenReport strDoc, acViewPreview, , strLinkCriteria, acWindowNormal
  10.  
  11. End Sub
  12.  
Notes:
  • strLinkCriteria is a string we build to act as the where statement of the report
  • strDoc is the report we want to open
  • Docmd.OpenReport is the command used to open the report with our specified parameters
  • if CustomerID is a text field rather than a number use this:
    Expand|Select|Wrap|Line Numbers
    1. strLinkCriteria = "[CustomerID] = '" & Me.CustomerID "'"
    2.  

Give this a try and if you need any help or clarification I'd be more than happy to assist.

Jking
It is opening up the report but it isn't showing any of the data. The code i have used is:

Private Sub Command690_Click()


Dim strLinkCriteria As String
Dim strDoc As String

strLinkCriteria = "[ID] = ' " & "Me.ID ' "
strDoc = "Customer"

DoCmd.OpenReport strDoc, acViewPreview, , strLinkCriteria, acWindowNormal

End Sub
Jul 31 '07 #3
JKing
1,206 Expert 1GB
Try changing this line:
Expand|Select|Wrap|Line Numbers
  1. strLinkCriteria = "[ID] = ' " & "Me.ID ' "
  2.  
To:
Expand|Select|Wrap|Line Numbers
  1. strLinkCriteria = "[ID] = '" & Me.ID & "'"
  2.  
You can see the difference very well with the colours from the code tags.

Edit: I see now this was my fault as I was missing a & in my previous post. Sorry for the confusion.
Jul 31 '07 #4

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

Similar topics

1
by: Wayne Aprato | last post by:
What can cause Access to bring up Runtime Error 2450 saying that it can't find a particular form when the form is definitely open? I am opening the form and then checking if fields are populated...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
2
by: ThompsonJessical | last post by:
I am trying to use a button with the vba coding for SendObject Function to email a specific report based on the value of another field of the current record. The form is a continuous form and...
2
by: gleave | last post by:
Hi. im trying to setup a filter for a report. Let me explain what I would like to achieve. I have a form called Invoicing, here all the data is put in about the invoice, I then have a report also...
2
by: Incolor | last post by:
Hello All! I have to generate a checklist form as an input form in Access. A paper form is taken out in the field and checked yes, no, OR n/a for each item inspected. The problem I am having is...
3
by: melnhed | last post by:
---Report the current filtered records from a Form--- Hello All, I've seen this topic discussed before, but the solution described then doesn't work in my particular case. My Config: ...
11
by: radink | last post by:
Hey All, I have a report that I would like to show a word on based on if a field is checked in a form. For example. The form has a check box called Fee. If that is checked, I want the word Paid...
2
by: phill86 | last post by:
Hi, I am filtering a report using the form filter with the following code DoCmd.OpenReport "report1", acViewReport, , Me.filter Which works fine untill I filter the form on one of the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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,...
0
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...

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.