Modules & VBA :: Generate Dynamic Report From Listboxes?
Jun 6, 2013
Is it possible to generate a report from 2 listboxes?
I have attached a pic of what I am trying to accomplish. I am wanting to have a report open with only the criteria that a user selects from the listboxes.
listbox 1: User selects a case number(s)
listbox 2: User selects the fields they would like in the report
So, if the user selects:
Case number: 13-001
Then selects fields:
Allegation
Incident date
Focus_Last name
This report would be:
Code:
Case Number Allegation Incident Date Focus_Last Name
13-001 DUI 06/01/2013 Doe
View Replies
ADVERTISEMENT
Jul 11, 2014
I am trying to concatinate string in a loop to generate a dynamic SQL to compare 2 tables. But I am not getting the result I want
Code:
Set rs = CurrentDb.OpenRecordset("r1")
Set rs2 = CurrentDb.OpenRecordset("r1_old")
columnCount = CurrentDb.TableDefs("r1").Fields.count
strSQL = ""
For I = 0 To columnCount
[Code] .....
I am trying to achieve something that reads like the following
r1.Field(0) = r2.Field(0) AND
r1.Field(1) = r2.Field(1) AND
r1.Field(2) = r2.Field(2) AND
.....
View 2 Replies
View Related
Jul 17, 2005
Hello,
I have two tables: Categories and Subcategories.
Categories contains one field: CategoryName
Subcategories contains two fields: ParentCategoryName and SubcategoryName.
In a third talbe I want to select a category from a listbox, then have the subcategory listbox update automatically with the possiblities. Is this possible?
Thanks.
View 1 Replies
View Related
May 20, 2015
I have a button that opens a report. The code behind the button builds the filter criteria for the report based on some selections in a list box.
Code:
DoCmd.openReport "Report", acViewPreview, "", GetCriteria
For VarItem = 0 To Me.List2.listcount - 1
strCriteria = strCriteria & "([ProjectNo]= '" & Me.List2.Column(1, VarItem) & "' And [ClientID] = " & Me.List2.Column(0, VarItem) & ") Or "
Next VarItem
If strCriteria <> "" Then
strCriteria = Left(strCriteria, Len(strCriteria) - 4)
Else
strCriteria = "True"
End If
GetCriteria = strCriteria
This is what the filter would look like with values after running the report (taken from filter bar in report properties):
([ProjectNo]= '150002' And [ClientID] = 206) Or ([ProjectNo]= '150003' And [ClientID] = 79)
Problem is that i only get records for ([ProjectNo]= '150002' And [ClientID] = 206). I this seems only filter ONE set of criteria ignoring all the others. What am i doing wrong?
View 5 Replies
View Related
Nov 22, 2014
This code runs to the set frm part then i get a type mismatch? ive tried a few different things and still nothing?
Code:
Private Sub Report_Open(Cancel As Integer)
' Create underlying recordset for report using criteria entered in
' EmployeeSalesDialogBox form.
Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form
' Set database variable to current database.
Set dbsReport = CurrentDb
[code]....
View 2 Replies
View Related
Jun 25, 2013
I'm still learning Access 2010 and having issues getting my buttons to work. I'm working on a simple address database.edit/save button. On form load, my fields are locked and my button will read "edit". After clicking, my fields are unlocked, my search features are locked, and my button reads "save" just how I need it to. The issue happens when I try and save the field edits, lock fields, return search features, and get button to read "edit" again. I know I need to add some code into what I already have, but I'm running into a wall as I have tried many options to get it to work. Here is the code for this button:
Code:
Private Function Lockdown() 'locks controls at load
Dim tb As Control
Dim cb As Control
Dim subf As Control
[code]...
Second issue is with my report button. I have not been able to get this to work once. I have done many searches on single record reports, and have found the same code every time. I added that code into my database, but can't seem to get it to work. In my database there are two address (shipping and work location) which I would like to print out together. I have the work location on the main form and the shipping on a subform. There are and upwards of 150 locations I will have in my database, Here is the code I'm working with:
Code:
Private Sub cmdrptadd_Click()
Dim strReportName As String
Dim strCriteria As String
[code]...
View 3 Replies
View Related
Oct 8, 2013
Is it possible to create a button that automatically saves a report as .pdf? And automatically generates the filename.
Like 0810-544 (0810 is the date and 544 is the ID from the form.)
View 14 Replies
View Related
Jun 30, 2006
I have a form that shows a list of all of my records in my database. I want to be able to click a button called "Report" and have that print a report that has all the records I have filtered on my form. I have a report in the format that i want it in, however, currently it prints every record and not just what is shown on my form. (The form is dynamic and I want the Report to be dynamically based on the form) HELP PLEASE!
View 6 Replies
View Related
Oct 15, 2013
I'm using VBA code to open a query, generate a report for a test and an answersheet. I'm using the same report, and don't want to make many reports. I have the below code which runs my query, and generates the reports.
Private Sub Command2_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "1", acViewNormal, acEdit
DoCmd.OpenReport "WrittenExam", acViewPreview, "", "", acNormal
DoCmd.OpenReport "WrittenExamAnswerSheet", acViewPreview, "", "", acNormal
End Sub
I have a need to be able to set the report title for both reports when running my code.
View 3 Replies
View Related
Nov 19, 2005
Good Morning all,
On a Form I have a series of Listboxes, each drills down to a final piece of information. The Listboxes store a number_id which displays along with other information In this case the number_id is associated to a TEXT description. When I send the Listbox info to the Report it displays the info but the text doesn't wrap and it gets cut off. There is no "can grow" option on a list box.
So I need to create a Text Box in the Report but when I refrence the listbox in the control source only the number_id shows up. I need to see the associated text (field).
Any help would be great!
Thanks,
Phil "bones"
View 2 Replies
View Related
Apr 16, 2015
My table "EmpTraining" will store 5 fields:ID (PK Autonumber )
EmpID (From Employees Table)
FleetName_ID ( From FleetList Table )
Engine1_ID (From EngineList Table )
Engine2_ID (From EngineList Table )
At the point of adding a record to EmpTraining table , EmpID and FleetName_ID and Engine1_ID are Required, Engine2_ID is optional.
I am having trouble generating a Report Filter that will use 3 Listboxes(multiselect) and be able to limit the report by what is selected.
My Listboxes filter:EmpBase (from Employees Table)
FleetName_ID ( From FleetList Table )
Engine1_ID (From EngineList Table )
I am trying to use the Third listbox to filter both Engine1_ID and Engine2_ID and I think this is my main problem.
On the Filter form that has the ListBoxes I use a button to apply the filter to the report, the code for this Onclick event is:
Code:
Private Sub btnApplyFilter_Click()
Dim varItem As Variant
Dim strBaseStation As String
Dim strFleetType As String
Dim strEngineType As String
[code]....
How can I also make it filter the Engine1_ID and Engine2_ID fields .?
Or Should I store the FleetName/Engine1/Engine2 in a different way?
View 3 Replies
View Related
Jun 27, 2014
I have a form with 2 listboxes: 1 to show the name of the products having a code "v" (recordsource query), 1 to show the name of the products having a code "a".
2 arrowed buttons (left-right) would make a product "jump" from one to the other.
The way I wanted to do this is, when the appropriate button is clicked, the actual product code is changed, then the listboxes refreshed, so that it looks that the product jumped listboxes (when the code changes and the listboxes refreshed/requeried, it will disappear in one and appear in the other, because of the recordsource queries).
I want to do it this way, because it is imperative that the code gets changed!
But how to get the record of the selected product "out" of the listbox. When I select a product and check e.g. the ".value" of the listbox, it is "null"!?
So how to "get" the record corresponding with the selected item in a listbox in VBA?
View 7 Replies
View Related
May 2, 2005
I want generate and load the report using vba when a command button is clicked . (automating the report generation)
For example i have table in access that has name, address and email fields and onced command button is clicked the report is
generated and loaded.I be happy if some one show me wprking example.Thanks
View 2 Replies
View Related
Jun 14, 2006
Hi,
I have the following very general question, but I hope you can give me a few hints so I can start and find things out on my way.
I just created a database which via VBA procedures runs all kinds of queries and puts the results in tables, for instance I have about 20 tables now with 10 fields each and for every table I want to run the same type of report.
I already made one report for one table via the report wizard, I would like to use the layout of this table for all other tables using a VBA code, so when I run this code it will create all these reports for me.
What is the best way to start?
Many thanks!
View 1 Replies
View Related
Aug 24, 2005
Hello to all,
I created a dynamic report based on cross tab query, the header is a sub report.
Number of lines and rows depend on the data typed in a form.
Here is my problem. When numbers of rows exceeds for exemple 15 the header and detail line continue on the line below i would like the report continue on another page (see below).
Actualy i have this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20
line1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
line2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
etc..
I would like this:
page 1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
line1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
line2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
etc...
Page 2:
16 17 18 19 20
line1xxxxxxxxx
line2xxxxxxxxx
etc...
THANKS IN ADVANCE FOR HELP.
VINCENT
View 2 Replies
View Related
Nov 30, 2004
I am using the following cde to generate a Dynamic Crosstab Report. I can get the column labels to work but Ican't get the values to appear in the detail section all I get is #Name?
I am using the following code in the report
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("select * from test2")
rst.MoveFirst
j = 0
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).NAME Like "*test" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.Field0.ControlSource = rst.Fields(i).NAME
Case 1
Me.Field1.ControlSource = rst.Fields(i).NAME
Case 2
Me.Field2.ControlSource = rst.Fields(i).NAME
Case 3
Me.Field3.ControlSource = rst.Fields(i).NAME
Case 4
Me.Field4.ControlSource = rst.Fields(i).NAME
Case 5
Me.Field5.ControlSource = rst.Fields(i).NAME
Case 6
Me.Field6.ControlSource = rst.Fields(i).NAME
Case 7
Me.Field7.ControlSource = rst.Fields(i).NAME
Case 8
Me.Field8.ControlSource = rst.Fields(i).NAME
Case 9
Me.Field9.ControlSource = rst.Fields(i).NAME
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("select * from test2")
rst.MoveFirst
j = 0
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).NAME Like "*test" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.Label0.Caption = rst.Fields(1).NAME
Case 1
Me.Label1.Caption = rst.Fields(i).NAME
Case 2
Me.Label2.Caption = rst.Fields(i).NAME
Case 3
Me.Label3.Caption = rst.Fields(i).NAME
Case 4
Me.Label4.Caption = rst.Fields(i).NAME
Case 5
Me.Label5.Caption = rst.Fields(i).NAME
Case 6
Me.Label6.Caption = rst.Fields(i).NAME
Case 7
Me.Label7.Caption = rst.Fields(i).NAME
Case 8
Me.Label8.Caption = rst.Fields(i).NAME
Case 9
Me.Label9.Caption = rst.Fields(i).NAME
End Select
skip_it:
Next
rst.Clone
Set rst = Nothing
End Sub
What else do I need to do to get data in the detail section
In anticipation
errolf
View 5 Replies
View Related
Oct 26, 2011
i have two combo box, one is cboMonth and one is cboYear. i am trying to get the values from these 2 combo box, and used the value to generate report. however, when i click the btnPrintSummary button, system keep prompting me to enter parameter value.
Code:
Private Sub btnPrintSummary_Click()
Dim stDocName As String
Dim stWhere As String
Dim blnTrim As Boolean
[code]...
View 3 Replies
View Related
Apr 2, 2013
I need to create a simple receipt on ms access.
Fields will include:
TransactionDate
ProductID
ProductName
UnitPrice
Quantity
SubTotal
Total
AmoundPaid
Balance
The subtotal= unitPrice*Quantity
Total = Addition of all subtotal
AmountPaid = How much each customer paid
Balance = AmountPaid - Total
fields the TABLE should contain? (Remember customers will purchase more than one product & there will be more than one reciept)..How I can generate a REPORT using a FORM ? The REPORT should contain the calculations. How do I make access do the caluclations?
View 2 Replies
View Related
Jan 6, 2005
Hi guys,
I’m creating a report on which I want to group data base on a field that has two different data one is KEY and OTHER. Now I need to be able to show on the detail section all records base on KEY, and group the rest of the records by OTHER.
Can anyone help me please?
Million of thanks
View 2 Replies
View Related
Nov 13, 2014
I have a crosstab Query as the source for my report, of course the issue is the column headings on the report. I have Purchasers as a row heading, Year as a row heading, Month/Year as a row heading, Meter as a column heading, PaidMCF as Value and, a total as a Row heading. My issue is feeding the column headings on my report with the meter names.
Purchaser 1 has 23 meters attached
Purchaser 2 has 1 meter attached
Purchaser 3 has 6 meters attached
Purchaser 4 has 2 meters attached
Purchaser 5 has 16 meters attached
Purchaser 6 has 11 meters attached.
View 4 Replies
View Related
Jul 28, 2013
I created a dynamic crosstab report with 4 unbound fields in the details section and 4 unbound fields in the header section, which all work perfectly well. The crosstab query contains 17 columns. The last 4 columns contain the values I need to take the sum of. I have put some code in the open event procedure of the report.
Private Sub Report_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from Que_ProjectUren_Sel_Dept_Test")
[code]...
View 11 Replies
View Related
Jul 3, 2014
I'm currently creating an invoicing report for a company, and for record purposes they need a dynamic field on the report for the specific Invoice Number of each client they invoice. I have the field set up currently as a text box =[Invoice#] so they have to enter an invoice number when they generate the report. However, when I generate the report and put in a number, I'm getting some whacky outputs.
For example, I've tested it with a test client, and when I give the client an invoice number of 1, the report somehow changes it to 49.
View 1 Replies
View Related
Jan 16, 2007
Hi everyone,
I am tring to generate a report or form, its generated by a combo box, which list all the categories of the products, when the category is clicked on it will generate the report or form showing all the products for that particular category. Can anyone point me in the right direction? Any help would be appreciated.
View 3 Replies
View Related
Jan 5, 2007
I have a report that prints blank serialized forms and I basically need a query to generate a field where if I request 4 sheets to be printed the list generated would look like this:
ClaimNo
1
2
3
4
It seems like this would be simple, but I'm a noob.
-aldo
View 1 Replies
View Related
Dec 27, 2007
The premise:
I’m trying to create a report that is based on one of the columns in my data set. This is a rather large database, but there are only a few variations in this column and I’d like to have a report of the individual variations.
The current fix:
I’ve been able to make a report of all the variations and they are organized within each group. I cannot get Access to make a report that has only one of the variations.
How I’m doing this:
I am currently trying to use a combo box to pick which variation I want. I created a table that is related to the main table, which only has the names of the individual variations (and none are repeating, so I believe that was done correctly).
Then I am using a command button to call the report format (I am using VB to do this).
The issues:
Rather than just displaying the single variation that I chose, the one I chose is highlighted and all of the others are showing up directly below it. Then all of the data sets are showing up.
The needed fix, I think:
I don’t think I have the combo box and the command button linked properly. Does anyone know how I should have the parameters set in the combo box and what command I need to include in VB to draw the information from the combo box?
View 7 Replies
View Related
Jan 20, 2015
I found the vba to generate multiple pdf's from a single report which is working well (see below).
The script below generates about 15 pdf files and stores them in the specified directory
I'd like to be able to now email these to the individual users (SCNAME) but cannot work out where to start, i've tried a lot of things from the research on emailing, just not working.
All the information I need is in one table which includes the users email address field (SCemail).
I've also created an update query which generates a unique file name into the field (SCInstallDate) (currently not using this field data)
Code:
Private Sub cmdSC2PDF_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT [SCNAME] FROM [Schedule];", dbOpenSnapshot)
Do While Not rst.EOF
strRptFilter = "[SCName] = " & Chr(34) & rst![SCNAME] & Chr(34)
[Code] .....
View 14 Replies
View Related