473,802 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Choice - Print or Preview

Jon
I'm trying to set an (within options table, tblOptions) a setting that can
be read, whehter all reports should be printed or previewed. I'm happy to
email a sample db if required. When I use the setting I get a Run-time error
'13' Type mismatch!!

I have:

1 table - tblOptions with
1 field - "PrintOrPreview " - a 50 character Text field
1 report - "rptTEST" - just a label on it
1 form - with a button and a combo box to chaing the vaule of
"PrintOrPreview "

The code for the combo box:

Private Sub cmbPrintOrPrevi ew_AfterUpdate( )
Call SetPrintChoice
End Sub

Which is:

Function SetPrintChoice( )
Dim rst As DAO.Recordset
Dim stSQL As String

stSQL = "SELECT * FROM tblOptions;"
Set rst = CurrentDb.OpenR ecordset(stSQL)

If rst.RecordCount > 0 Then 'in case the options record
has gone!
rst.MoveFirst 'in case another
record was added by mistake!
Select Case rst("PrintOrPre view")
Case "ChooseToPrevie w"
gblPrintOrPrevi ew = "acViewPrev iew"
Case "ChooseToPr int"
gblPrintOrPrevi ew = "acViewNorm al"
Case Else
gblPrintOrPrevi ew = "acViewPrev iew"
End Select
'let's see what it's showing....
Debug.Print "Print setting: " & gblPrintOrPrevi ew
End If
End Function

And finally the code for the button:

Private Sub cmdPrint_Click( )
' DoCmd.OpenRepor t "rptTEST", acViewNormal
' DoCmd.OpenRepor t "rptTEST", acViewPreview

'Either of these work, but as soon as I change it to
DoCmd.OpenRepor t "rptTEST", gblPrintOrPrevi ew
'then I get a "Type mismatch Error"

End Sub

=============== ============

Surely this has been done before! What am I do wrong? Please help if you
can, thank you

Jon


Nov 13 '05 #1
3 1812

"Jon" <jon@SPAM_OFFth eexperts.co.uk> wrote in message
news:da******** **@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...
I'm trying to set an (within options table, tblOptions) a setting that can
be read, whehter all reports should be printed or previewed. I'm happy to
email a sample db if required. When I use the setting I get a Run-time error '13' Type mismatch!!

I have:

1 table - tblOptions with
1 field - "PrintOrPreview " - a 50 character Text field
1 report - "rptTEST" - just a label on it
1 form - with a button and a combo box to chaing the vaule of
"PrintOrPreview "

The code for the combo box:

Private Sub cmbPrintOrPrevi ew_AfterUpdate( )
Call SetPrintChoice
End Sub

Which is:

Function SetPrintChoice( )
Dim rst As DAO.Recordset
Dim stSQL As String

stSQL = "SELECT * FROM tblOptions;"
Set rst = CurrentDb.OpenR ecordset(stSQL)

If rst.RecordCount > 0 Then 'in case the options record has gone!
rst.MoveFirst 'in case another
record was added by mistake!
Select Case rst("PrintOrPre view")
Case "ChooseToPrevie w"
gblPrintOrPrevi ew = "acViewPrev iew"
Case "ChooseToPr int"
gblPrintOrPrevi ew = "acViewNorm al"
Case Else
gblPrintOrPrevi ew = "acViewPrev iew"
End Select
'let's see what it's showing....
Debug.Print "Print setting: " & gblPrintOrPrevi ew
End If
End Function

And finally the code for the button:

Private Sub cmdPrint_Click( )
' DoCmd.OpenRepor t "rptTEST", acViewNormal
' DoCmd.OpenRepor t "rptTEST", acViewPreview

'Either of these work, but as soon as I change it to
DoCmd.OpenRepor t "rptTEST", gblPrintOrPrevi ew
'then I get a "Type mismatch Error"

End Sub

=============== ============

Surely this has been done before! What am I do wrong? Please help if you
can, thank you

Jon


I can see why this is confusing. The second argument for DoCmd.OpenRepor t
needs to be numeric. Go to the debug screen and try this:

?acviewnormal
0
?acviewpreview
2

Notice that those constants are numeric. You are setting gblPrintOrPrevi ew
to a string value. You need to, either use a select/case statement and then
the appropriate constant, or set gblPrintOrPrevi ew to a numeric value to
begin with.

HTH,
Randy

Nov 13 '05 #2
You use string literals where you should use constants.

Jon wrote:
gblPrintOrPrevi ew = "acViewPrev iew"


must become
gblPrintOrPrevi ew = acviewpreview

You don't need to use a global variable if you convert the
SetPrintChoice sub to a GetPrintChoice function, assigning the value
found in the table to the function result, and calling that in the
OpenReport method. But that is a different issue.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Nov 13 '05 #3
Jon

Bas Cost Budde Wrote:
You use string literals where you should use constants.
Jon wrote: gblPrintOrPrevi ew = "acViewPrev iew"


must become
gblPrintOrPrevi ew = acviewpreview

You don't need to use a global variable if you convert the
SetPrintChoice sub to a GetPrintChoice function, assigning the value
found in the table to the function result, and calling that in the
OpenReport method. But that is a different issue.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Bas and Randy, thank you. It's a sub in my test DB, was a function before!

I now understand where I was going wrong and will sort this - thank you.

Jon
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
14380
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to display the graph but it is not possible to send query parameters to an OLE graph on a report (or programatically change any properties of an OLE Graph). However with a Form you do have the ability to change the RowSource of
1
17683
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 Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
0
427
by: CSDunn | last post by:
Hello, I have a format issue on an Access 2000 ADP report that I am going to attempt to explain from a 'ten thousand foot view' : I have an Access 2000 ADP report that has a SQL Server 2000 Stored Procedure as its record source. The Proc is called MM_rptTeacherGroupingTest_sp. In order to help communicate the issue I am having with the report, please take a look at the following: http://www.valverde.edu/home/policy/ReportLayout.htm .
0
2026
by: John | last post by:
I have a class that creates an AxWebBrowser object in the background, loads some arbitrary html content, then shows the user a print preview. The only problem is, this print preview is a tiny little window on the top left hand corner of the screen. Thinking that this may have something to do with the Print Preview dialog not being able to detect from it's caller's size so that it can set its own size equal to that of the caller, I...
2
14137
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002 database? Thanks, Dean Slindee
2
2947
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic sub-report will capture what grades the student has achieved in a list of different subjects and the reason I need it to be dynamic is that students take different subjects. Basically I've been trying to doctor the KB article on dynamic
6
3476
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page and not show the templated fields, (hyperlinks) and also not print those fields?
9
4080
by: igotyourdotnet | last post by:
I need to create a print preview page BUT my page I need to print has a grid and in the grid I have 2 or 3 columns that have links I want to hide the columns with the links on my print preview page so they don't print. Is that possible to do and if so can someone point me somewhere or show my a code snippet on how to do this?
11
7343
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What command do I use in code to find out if a report (or any other object for that matter) is already...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.