Codes for Screen active form

N

Nandini

I created autokeys macro to open "MyHelpForm" through F1 key or shortcut
menu. For this I have created a table having 3 fields 'FormName' , 'CtrlName'
and 'HelpText'. In the standard module I wrote following code:

Public Function OpenMyHelpForm()

Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl

DoCmd.OpenForm "MyHelpForm", , , "FormName= '[Screen].[ActiveForm].[Name]'"
DoCmd.OpenForm "MyHelpForm", , , "CtrlName =
'[Screen].[ActiveForm].[ActiveControl].[Name]'"
End Function

MyHelpForm is opened after pressing F1, but it dosent show any record. I
used Access 2003. Anybody can help me anyway? I dont have much more knowledge
about visual basic codes.
Early response would be appreciated.
With best regards,
 
D

Duane Hookom

Try:

Public Function OpenMyHelpForm()
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl
Dim strWhere as String
strWhere = "FormName= '" & frmCurrentForm.[Name] & _
"' AND CtrlName = '" & ctlCurrentControl.[Name] & "'"
MsgBox "strWhere: " & strWhere
DoCmd.OpenForm "MyHelpForm", , , strWhere
End Function
 
N

Nandini

Duane Hookom,
I have done as I wanted. Thanks a lot for your kind help.
with best regards,
--
nandini


Duane Hookom said:
Try:

Public Function OpenMyHelpForm()
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl
Dim strWhere as String
strWhere = "FormName= '" & frmCurrentForm.[Name] & _
"' AND CtrlName = '" & ctlCurrentControl.[Name] & "'"
MsgBox "strWhere: " & strWhere
DoCmd.OpenForm "MyHelpForm", , , strWhere
End Function

--
Duane Hookom
Microsoft Access MVP


Nandini said:
I created autokeys macro to open "MyHelpForm" through F1 key or shortcut
menu. For this I have created a table having 3 fields 'FormName' , 'CtrlName'
and 'HelpText'. In the standard module I wrote following code:

Public Function OpenMyHelpForm()

Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl

DoCmd.OpenForm "MyHelpForm", , , "FormName= '[Screen].[ActiveForm].[Name]'"
DoCmd.OpenForm "MyHelpForm", , , "CtrlName =
'[Screen].[ActiveForm].[ActiveControl].[Name]'"
End Function

MyHelpForm is opened after pressing F1, but it dosent show any record. I
used Access 2003. Anybody can help me anyway? I dont have much more knowledge
about visual basic codes.
Early response would be appreciated.
With best regards,
 

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