Solved

Printing crviewer control by pressing one key only

Posted on 2003-11-02
8
471 Views
Last Modified: 2008-01-09
Hi, I have a form (frmReport) which has one control on it (crvReport).

What I would like is when you press the "/" (Asc(47)) button the form must close and when pressing the "*" (Asc(42))  button the form must print and close.

The trouble is there is no keyboard event for the crviewer control.

What can I try?

TIA
0
Comment
Question by:jinxster
  • 3
  • 2
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9668698
Nothing in CR that I am aware of since it cannot respond to a keypress event.

I wonder if you could put a timer on the form and have it check for a keypress through Windows API calls.  I don't know how to do it but it might be possible.

mlmcc

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9670532
?

If you set keypreview to true on the form, you should get the form's key_press event.
Am I missing something?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9671054
Eddy - The Crystal control only exposes the click events.

mlmcc
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Accepted Solution

by:
jinxster earned 0 total points
ID: 9672002
Hi, Eddy, the keypreview property means that if controls on the form have a key(press, up, down) but nothing is inside, the form's key(press, up, down) prevails.

I found a work around, (without using API)

Basically, it goes like this:

Add a textbox on the form and make sure it is behind the crviewer control.
Write the necessary code in the key_press, key_down, key_up events of the textbox.
In the viewchanged AND gotfocus event of the crviewer control add: textbox.SetFocus

The events should work. This also works nicely to make page up and page down scroll through pages home goto first page, end goto last, etc.

Thanks.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10170900
PAQ.  no refund unless he responds
0
 

Author Comment

by:jinxster
ID: 10176313
I gave my own solution so I do not feel anyone really earned any points, sorry.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now