AutoKeys macro

G

Guest

Hi, i have an autokeys macro that i have until now used to open different
forms when a specific 'F' key is pressed. however, now i have created a
option group on a form and i would like each 'F' key to open each option. is
there any way i can do this?
if it is of any help, have made a screanshot of the form which is located at
http://www.computingforum.co.uk/icewolf/screenshot.PNG

Any help would be much appreciated,
Yours,
Colin Field
 
S

Steve Schapel

Colin,

Do you mean the buttons along the top of your form? Do you have a macro
you want to run on the After Update event of the Option Group, depending
on which option is selected? If so, you could use your AutoKeys macro
like this (for example):

Macro Name: {F4}
Action: SetValue
Item: [NameOfYourOptionGroup]
Expression: 4
Action: RunMacro
Macro Name: YourAfterUpdateMacro
 
G

Guest

Hi thanks for your reply, i have tried what you have suggested and it works
to the extent of selecting the option button, but in the after update section
of the group i have some VB code and this fails to run when i use the F keys
:(
The code that i have is this:
Private Sub HouseIDFilters_AfterUpdate()
Dim sSQL As String

Select Case Me!HouseIDFilters.Value
Case 1: sSQL = "SELECT [K].[ID], [K].[Name] FROM [K]"
Case 2: sSQL = "SELECT [R].[ID], [R].[Name] FROM [R]"
Case 3: sSQL = "SELECT [WY].[ID], [WY].[Name] FROM [WY]"
Case 4: sSQL = "SELECT [WN].[ID], [WN].[Name] FROM [WN]"
Case 5: sSQL = "SELECT [C].[ID], [C].[Name] FROM [C]"
Case 6: sSQL = "SELECT [WF].[ID], [WF].[Name] FROM [WF]"
Case 7: sSQL = "SELECT [M].[ID], [M].[Name] FROM [M]"
Case 8: sSQL = "SELECT [H].[ID], [H].[Name] FROM [H]"
Case 9: sSQL = "SELECT [A].[ID], [A].[Name] FROM [A]"

End Select

Me!ListBox.RowSource = sSQL
Me!ListBox.SetFocus
DoCmd.RunMacro "HseFilters"
If Me!HouseIDFilters.Value = 1 Then Forms!EPOS!Title.Caption = "Kitchener
House" Else: If Me!HouseIDFilters.Value = 2 Then Forms!EPOS!Title.Caption =
"Roberts House" Else: If Me!HouseIDFilters.Value = 3 Then
Forms!EPOS!Title.Caption = "Wolseley House" Else: If Me!HouseIDFilters.Value
= 4 Then Forms!EPOS!Title.Caption = "Wellington House" Else: If
Me!HouseIDFilters.Value = 5 Then Forms!EPOS!Title.Caption = "Clive House"
Else: If Me!HouseIDFilters.Value = 6 Then Forms!EPOS!Title.Caption = "Wolfe
House" Else: If Me!HouseIDFilters.Value = 7 Then Forms!EPOS!Title.Caption =
"Marlborough House" Else: If Me!HouseIDFilters.Value = 8 Then
Forms!EPOS!Title.Caption = "Haig House" Else: If Me!HouseIDFilters.Value = 9
Then Forms!EPOS!Title.Caption = "Alanbrooke House"
End Sub

Thankyou very much for your help,
Colin Field

Steve Schapel said:
Colin,

Do you mean the buttons along the top of your form? Do you have a macro
you want to run on the After Update event of the Option Group, depending
on which option is selected? If so, you could use your AutoKeys macro
like this (for example):

Macro Name: {F4}
Action: SetValue
Item: [NameOfYourOptionGroup]
Expression: 4
Action: RunMacro
Macro Name: YourAfterUpdateMacro

--
Steve Schapel, Microsoft Access MVP


Colin said:
Hi, i have an autokeys macro that i have until now used to open different
forms when a specific 'F' key is pressed. however, now i have created a
option group on a form and i would like each 'F' key to open each option. is
there any way i can do this?
if it is of any help, have made a screanshot of the form which is located at
http://www.computingforum.co.uk/icewolf/screenshot.PNG

Any help would be much appreciated,
Yours,
Colin Field
 
S

Steve Schapel

Colin

Setting the value of the Option Group via a macro will not cause its
After Update event to fire. You will have to explicitly make this
happen in the macro. One way to do this would be to use SetValue
actions in the macro itself to manipulate the Row Source of your
ListBox, and the Caption of the Title. Another way would be to save the
VBA procedure as a Public Function, and then use a RunCode action in
your macro to make it happen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top