Multiple Reports, Single Open Report Button

MrGenius

New member
Local time
Today, 13:16
Joined
Jan 9, 2010
Messages
4
Greetings,

I have a form that collects data through 3 queries;



(A) Search box

(B) Area

(C) Category



I want to use a macro or any other way that you may suggest to make the following possible:



(A) Setfocus to Search box when the form open

(B) If the user uses a key combination like SHIFT+F2 it will auto fill the area cbox



for example:



Shift+F2 = CA

Shift+F3 = NY

Shift+F4 = Rome

Shift+F5 = London



and after applying the key combination set focus to search button

on the other end I have about 10 reports based on the category and the area selection I want the very same search button to generate each one of them according to the relevance of user select in area and category in the form to the report.


is there anyway possible to achieve it?
 
Looking at my notes, I think you can detect the Shift key like this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift And acShiftMask) <> 0 Then MsgBox "Shift Key"
End Sub

You also need to know the keycodes for the F-keys (you can get this by testing). Hit the F2 key and then output the keycode value in a msgbox (turns out to be 113).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub

Once you know the keycode is 113 you can put it to use:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if KeyCode = 113 Then ....' user hit F2
End Sub


If you want to populate a combobox dynamically, use a table or query

cbo.RowSourceType = "Table/Query"
cbo.RowSource = "SELECT Area FROM AreaTable WHERE Country= 'London' "

Let us know where you are having problems.
 
Actually the first part may have related to my question however,

I see that in the Sub you used the populated event keydown, I think there is a misunderstand in what I am looking for. let me try to explain it furthermore;

I have a combobox dynamically populated, and working fine, but instead of making the user select from combobox I want to assign hotkeys to each item in the combobox

for example I have England and Italy listed, so If user presses a combination of SHIFT and F2, the combobox set item will change to Italy, and If SHift and F3, it will change to England...etc

my other question is, I have about 10 reports designed to serve different queries, what I want to do is; through a single button on the form, I can open any of the reports based on the category and area selection from the two other comboxboxes....

Best Regards
J

Looking at my notes, I think you can detect the Shift key like this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift And acShiftMask) <> 0 Then MsgBox "Shift Key"
End Sub

You also need to know the keycodes for the F-keys (you can get this by testing). Hit the F2 key and then output the keycode value in a msgbox (turns out to be 113).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub

Once you know the keycode is 113 you can put it to use:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if KeyCode = 113 Then ....' user hit F2
End Sub


If you want to populate a combobox dynamically, use a table or query

cbo.RowSourceType = "Table/Query"
cbo.RowSource = "SELECT Area FROM AreaTable WHERE Country= 'London' "

Let us know where you are having problems.
 
I have a combobox dynamically populated, and working fine, but instead of making the user select from combobox I want to assign hotkeys to each item in the combobox

for example I have England and Italy listed, so If user presses a combination of SHIFT and F2, the combobox set item will change to Italy, and If SHift and F3, it will change to England...etc
I thought that was the code I gave you. In order to accomplish this, you will presumably need to detect those keys using keydown (or some other event) like I suggested.

If you want to select a given item in the combobox, you can do it using the rownumber:

For rowNo = 0 To lb.ListCount - 1
lb.Selected(rowNo) = True
Next i

If you want to poll for an item on the current row:

if cbo.Column(colNo, rowNo) = strSomeString

my other question is, I have about 10 reports designed to serve different queries, what I want to do is; through a single button on the form, I can open any of the reports based on the category and area selection from the two other comboxboxes....
But what part of this isn't working? And what part of this does work? In all fairness, be specific as to where you are having a problem.
 
well actually,

my issue is the following, I don't want to assign any of them to a pre-based event, but a specific set of keys which I don't know how to code it.

on the other end, the reports I tried lately doing it through the Select Case and the IF Then Statement with the Docmd.OpenReport

however it prints the report instead of viewing it.
 
You want hot keys to trigger a report without setting up an event? I doubt there is a way to do so. Nor can I fathom the advantage of doing so.

Then you said that the report prints instead of displaying? That's odd. Normally a report will display by default (DoCmd.OpenReport), and then extra code is needed to print it.

As I'm not understanding anything you say, I'm leaving this thread. Sorry I wasn't able to help.
 

Users who are viewing this thread

Back
Top Bottom