- Banned
- #1
First of all I'm not even an amateur in access VBA, I'm the definition of beginner. So, if I'm not explaining very well what I need, please try to be patient with me . Thank in advance!
I'm creating a database in Access 2016 (with the help of one colleague) which looks like an old software with toolbar and submenus and it seems very tedious to write the same procedure for every click or MouseDown, therefore I'm trying to find a way to introduce a procedure (INSIDE A MODULE) which uses a variable to detect the button which was clicked/hovered over inside any form of my project. I also need a variable to detect the last form opened.
I tried to use two text boxes so I can extract the names of every button/form and use the value inside these text boxes to create the variable mentioned above.
When I started to work on this project I named every button using the caption of the button & the extension "bt"
Example:
"File" button is named "filebt"
I used the same method on forms and subforms:
Example:
When I press the "File" button it opens a form, which is named "filefm" inside a subform, which is called "filesfm"
'---"File" button action---
'-click action-
Private Sub filebt_Click()
btnmbx = "File"
If Form_filefm.Visible = False Then
Form_filefm.Visible = True
Form_Initialize.Filebt.SetFocus
Form_editfm.Visible = False
Form_purpfm.Visible = False
Else: Form_filefm.Visible = False
End If
If Form_filefm.Visible = True Then
fmnmbx.Value = Filebt.Caption
Else: fmnmbx.Value = ""
End If
End Sub
'-hover action-
Private Sub Filebt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
btnmbx = "File"
'btnmbx - BuTtonNaMeBoX
If Form_editfm.Visible = True Or (Form_optionsfm.Visible = True) Then
Form_editfm.Visible = False
Form_filefm.Visible = True
Form_Initialize.Filebt.SetFocus
Form_editfm.Visible = False
Form_editfm.Visible = False
Form_purpfm.Visible = False
fmnmbx.Value = "File"
'fmnmbx - ForMNaMeBoX
End If
End Sub
This project will suffer many changes until we're going to finish it, so I figured I will need some variables to be able to call a procedure instead of writing it every time I'm adding a button or a form.
Thanks again!
Eugen
I'm creating a database in Access 2016 (with the help of one colleague) which looks like an old software with toolbar and submenus and it seems very tedious to write the same procedure for every click or MouseDown, therefore I'm trying to find a way to introduce a procedure (INSIDE A MODULE) which uses a variable to detect the button which was clicked/hovered over inside any form of my project. I also need a variable to detect the last form opened.
I tried to use two text boxes so I can extract the names of every button/form and use the value inside these text boxes to create the variable mentioned above.
When I started to work on this project I named every button using the caption of the button & the extension "bt"
Example:
"File" button is named "filebt"
I used the same method on forms and subforms:
Example:
When I press the "File" button it opens a form, which is named "filefm" inside a subform, which is called "filesfm"
'---"File" button action---
'-click action-
Private Sub filebt_Click()
btnmbx = "File"
If Form_filefm.Visible = False Then
Form_filefm.Visible = True
Form_Initialize.Filebt.SetFocus
Form_editfm.Visible = False
Form_purpfm.Visible = False
Else: Form_filefm.Visible = False
End If
If Form_filefm.Visible = True Then
fmnmbx.Value = Filebt.Caption
Else: fmnmbx.Value = ""
End If
End Sub
'-hover action-
Private Sub Filebt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
btnmbx = "File"
'btnmbx - BuTtonNaMeBoX
If Form_editfm.Visible = True Or (Form_optionsfm.Visible = True) Then
Form_editfm.Visible = False
Form_filefm.Visible = True
Form_Initialize.Filebt.SetFocus
Form_editfm.Visible = False
Form_editfm.Visible = False
Form_purpfm.Visible = False
fmnmbx.Value = "File"
'fmnmbx - ForMNaMeBoX
End If
End Sub
This project will suffer many changes until we're going to finish it, so I figured I will need some variables to be able to call a procedure instead of writing it every time I'm adding a button or a form.
Thanks again!
Eugen