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

Printing a report from a command button on a form

25
Hello Everyone!

I am trying to use the following code in an on click event procedure from a command button on a custom form set as a dialog box. The dialog box is opened from another form. The dialog box contains a list box[List1] & two command buttons "Print & Cancel". The list box has three columns taken from a table and is bound to the third column [ID]
The following code in the print command button.

Expand|Select|Wrap|Line Numbers
  1. Dim WClause
  2.     WClause = "[ID] = '" &[List1] & " ' "
  3.     DoCmd.OpenReport "Print One Uncomplete Report", whereCondition:=WClause
The problem is that I get a type mismatch error when the code is executed.
If I bind the list box to one of the other columns and change my code to reflect that field name it works fine.
The [ID] column is a numeric field in my table and also the primary key. The other columns in[List0] and my table are text. Is this why I get the error with the [ID] column? Because it is numeric? How can I make this work with the numeric column?

Thanks in Advance!
Jan 4 '07 #1
4 2271
NeoPa
32,556 Expert Mod 16PB
1. Line 2 - & " ' " should not have a space before the ' (If it's numeric the (')s shouldn't be there at all).
2. Line 3 - When calling a procedure, parameters may be passed positionally or by name. It is not possible to mix the two as you have tried to do here. The line should be :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport ReportName:="Print One Uncomplete Report",WhereCondition:=WClause
HTH.
Jan 4 '07 #2
teric2
25
Thank You!
I will give this I try as sson as I get to work this P.M.

I realize the spaces should not have been there I only added them because it was difficult to see what was there with out them. Guess I should have left it as it was. sorry.

I will make the adjustments you suggested, retry, and let you know.

Thanks Again!
Jan 4 '07 #3
teric2
25
Thank you so much!

After making your changes, my code executed perfectly.

Thank you so much for taking the time to answer.
You guys are great!
Just a little info for you. I work for a manufacturing facility of a large worldwide corporation. I was asked to develop a few files in Access to reside on our network that will be shared among depts. This is not what I was hired for but I have a little education in Access. (Very little, but more than anyone else here).

Most of the users here only have limited p.c. skills, so everything I do must have a simple interface. Therefore I have to create lots of forms with command buttons and try to keep my files secure so people can't poke around and mess with my code or macros.
Anyway, Enough with boring you, I'm sure I will be back for more help
and Thanks again.
Jan 4 '07 #4
NeoPa
32,556 Expert Mod 16PB
Not boring at all.
It's nice to know that we are helping real people with real lives and all.
Puts colour to the picture.
Jan 4 '07 #5

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

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
1
by: ManuelC | last post by:
Hi I have a form that contains a multiselect listbox (simple multiselect) and a command button. The listbox shows a list of all reports (about 20) available for users to print and the command...
1
by: gino | last post by:
I use Access 2000. I have problems where my Report hides behind the Form. if i close the Form, i then see my report. which is not what i want. i have in my form, Popup=yes, modal=No. i have a...
3
by: Birky | last post by:
I have a report which I am opening from a command button within a form. I am using the “DoCmd.OpenReport stDocName” command to open the report but it is automatically printing instead of popping the...
3
by: rush2112 | last post by:
First of all, I'm a nebie at VB code.......so be gentle. I need to print up to 25 reports at the click of a button, but I want to select which reports to print based on whther or not I have a check...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: goldxr | last post by:
Hi I'm pretty new to access and have very little VBA experience, so I apolgise if its a stupid question but I can't seem to figure this one out. I have constructed a main form with different pivot...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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?

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.