I have a continuous form [ProjectList] with 16 different fields on it.
I would like to be able to double click on any of the fields and open a tabbed single form to a particular tab. I have code to do that below.
What I am wondering is what is the best way to repeat the same event for lots of different controls? I can certainly make it work by just repeating the code for each control_event.
I have the majority of the code in another sub "OpenFormToPage()" that I call in my "AmountDue_DblClick" sub.
Here is the entirety (well relevent code) of my forms code. Note: this is only for double clicking on "AmountDue".
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Compare Database
Dim btPageToOpenTo As Byte
Dim stFormtoOpen As String
'-----------------------------------------------------------
Private Sub AmountDue_DblClick(Cancel As Integer)
stFormtoOpen = "Projects"
btPageToOpenTo = 4
OpenFormToPage
End Sub
'-----------------------------------------------------------
Private Sub OpenFormToPage()
On Error GoTo Err_OpenFormToPage
Dim stLinkCriteria As String
stLinkCriteria = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
DoCmd.OpenForm stFormtoOpen, , , stLinkCriteria
Forms(stFormtoOpen).TabCtl0.Pages(btPageToOpenTo).SetFocus
Exit_OpenFormToPage:
Exit Sub
Err_OpenFormToPage:
MsgBox Err.Description
Resume Exit_OpenFormToPage
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I would like to be able to double click on any of the fields and open a tabbed single form to a particular tab. I have code to do that below.
What I am wondering is what is the best way to repeat the same event for lots of different controls? I can certainly make it work by just repeating the code for each control_event.
I have the majority of the code in another sub "OpenFormToPage()" that I call in my "AmountDue_DblClick" sub.
Here is the entirety (well relevent code) of my forms code. Note: this is only for double clicking on "AmountDue".
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Compare Database
Dim btPageToOpenTo As Byte
Dim stFormtoOpen As String
'-----------------------------------------------------------
Private Sub AmountDue_DblClick(Cancel As Integer)
stFormtoOpen = "Projects"
btPageToOpenTo = 4
OpenFormToPage
End Sub
'-----------------------------------------------------------
Private Sub OpenFormToPage()
On Error GoTo Err_OpenFormToPage
Dim stLinkCriteria As String
stLinkCriteria = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
DoCmd.OpenForm stFormtoOpen, , , stLinkCriteria
Forms(stFormtoOpen).TabCtl0.Pages(btPageToOpenTo).SetFocus
Exit_OpenFormToPage:
Exit Sub
Err_OpenFormToPage:
MsgBox Err.Description
Resume Exit_OpenFormToPage
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++