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

open report from selection in combobox

64 64KB
Hi,

I use a table of reports to be able to select the right report.
In the table i have the fields;

ID_rap
Rap_naam - the name the user will see in the cmb_rapselect
Rap_cat - category of the report
Rap_rapselect - the real name of the report (the name i have to use if i want the report to show

I made a Query called Q_raps which lists all fields of the table.

On a form i have 2 comboboxes;

cmb_rapcat
cmb_rap_rapselect

The first combo lists the categories from the Qyery. Works fine

The second combo the lists all reports from the category choosen in the first combo. The list consists of the names that the user sees, not the actual name of the report which is in the field [rap_nameselect]

I now have a button on the form which, when clicked, should produce the report based on the report selected in the combo cmb_rapselect]. However, if i do that it will say that there is no report with that name.

The code for the button;
Expand|Select|Wrap|Line Numbers
  1. Private Sub but_rapprint_Click()
  2. Dim strQL As String
  3. Dim rapsel As String
  4. strSQL = "SELECT * FROM Q_raps "
  5. strSQL = strSQL & "WHERE [Rap_naam] = me.[cmb_rap_rapselect]"
  6. rapsel = [Rap_select]
  7. DoCmd.OpenReport rapsel, acViewReport
  8. End Sub
  9.  
The code does not work....but i think iám close ?
How can i make the button look at the right field called [Rap_select]?

Help would be much appreciated.
Thanks in advance.
Pierkes
Jul 25 '14 #1

✓ answered by twinnyfo

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport Me.cmb_rap_rapselect.Column(3), acViewReport
You can't open a Report just based ona query.

5 2903
twinnyfo
3,653 Expert Mod 2GB
You are very close.

Since your query includes all the fields, use the column property of the combo box:

Expand|Select|Wrap|Line Numbers
  1. Me.cmb_rap_rapselect.Column(3)
Use column 3, because the column numbers start at 0, and I believe your fourth column should be the real Report name, correct?
Jul 25 '14 #2
Pierkes
64 64KB
@twinnyfo
Hi, I now have this code;

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM Q_raps "
  2. strSQL = strSQL & "WHERE [Rap_select] = me.[cmb_rap_rapselect].Column(3)"
  3. DoCmd.OpenReport strSQL, acViewReport
  4.  
However, it does not open the report. It gives the message that it cannot open a report with the name '
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM Q_raps "
  2. strSQL = strSQL & "WHERE [Rap_select] = me.[cmb_rap_rapselect].Column(3)"
What am i doing wrong ?
Thanks, Pierkes
Jul 25 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport Me.cmb_rap_rapselect.Column(3), acViewReport
You can't open a Report just based ona query.
Jul 25 '14 #4
Pierkes
64 64KB
Hi Twinnyfo,

Thanks for helping me.
The only code i have left now is;

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport Me.cmb_rap_rapselect.Column(3), acViewReport 
However, now it gives an error because "the action or method requires a Report Name argument"

Any ideas ?
Regards,
Pierkes
Jul 25 '14 #5
Pierkes
64 64KB
Hi Twinnyfo,

I managed !!!
I had the bound column for the combobax wrong. I set it to column 3 an it worked !

The code is now very simple;

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport Me.cmb_rap_rapselect, acViewReport
  2.  
Thanks for your kind help !!
Pierkes
Jul 25 '14 #6

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

Similar topics

1
by: Dalan | last post by:
I'm developing a report selection form and one of the elements of design is providing Date from/to text boxes. I have a Table that contains all of the information regarding the reports and did...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October,...
8
by: Beany | last post by:
Hi, I have a table called tab_main with all the mobile phone users details. I have form with contains a combobox that lists all the users names alphabetically. i would like to select a name...
5
reginaldmerritt
by: reginaldmerritt | last post by:
Hello I'm creating a database application to manage our training centre. This includes registering candidates on courses\programmes. I have a table (‘registrations’) that holds this information...
7
by: martin DH | last post by:
Hello, I have a report that I open that pull its data from a form that builds a where string. Opening the report first opens the form, where I enter criteria, and then pulls matching records from a...
0
by: Andrus | last post by:
SWF ComboBox dropdown menu first item selection must open picklist. For this I use the following code: protected override void OnSelectedIndexChanged(System.EventArgs e) { if (SelectedIndex != 0...
4
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel As Integer) MsgBox "There are no errors in...
4
by: pacarv | last post by:
I've created a database in Access 2003 with multiple reports that are accessable from the switchboard. The switchboard also has a print button. The user selects the report from the menu which then...
2
by: Panos Antoniad | last post by:
Hello, I have a standard select form which I want to keep open after selection in order to allow for multiple selections without having to take space at the page (when using the "multiple"...
8
by: trivanka | last post by:
How to open report directly in Access 2010 when we open the file? Under options - Current Database, I see Display Form. Do I need to write a VBA code for this and if so, which event. I also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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:
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
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,...

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.