D
Dale Fye
I've got a shortcut (popup) menu that I want to use with several forms. It
is a simple menu and function call, but I would like to avoid multiple
similar copies of the shortcut menu or function that the menu implements to
just handle the name of a table. Basically, the popup calls a function
(fnSelect) and passes it a value (-1, 0, or 1) which will determine whether a
field (IsSelected) in the table of interest is set to true, false, or is
inverted.
The challenge I'm having determining what table to use. I'd like to use
this same menu for three different forms (each using a separate table as its
RecordSource), all of which are either subforms, or sub-subforms. I wrongly
assumed that I could refer to the Screen.ActiveForm to identify the form that
the shortcut was activated from, but that did not work. I then tried
Screen.Activeform.ActiveControl, and got the control name of the subform that
was active, but that did not help for identfying the sub-subform. I'm stuck
at:
Public Function fnSelect(OptionValue as integer) as boolean
Dim TableName as string
Dim strSQL as string
'Need a way to determine which sub or sub-sub form the
'shortcut menu was activiated from. This worked for a
'sub-form, but not for a sub-sub form
Select Case Screen.Activeform.ActiveControl
Case "frm_1"
TableName = "tbl_1"
Case "frm_2"
TableName = "tbl_2"
Case "frm_3"
TableName = "tbl_3"
Case Else
Goto SelectError
End Select
strSQL = "UPDATE [" & TableName & "] " _
& "SET [IsSelected] = " & iif(OptionValue = 1, _
" NOT
[isSelected]", _
OptionValue) & " " _
& "WHERE [Act_ID] = " & Forms("frm_Activities").txt_Act_ID
Currentdb.execute strsql, dbFailOnError
'Insert a line here to requery the appropriate sub or sub-sub form
SelectExit:
fnSelect = true
Exit Function
SelectError:
msgbox "Error updating IsSelected in table '" & TableName & "'"
fnSelect = false
End Function
Would appreciate any help I can get. Thanks.
is a simple menu and function call, but I would like to avoid multiple
similar copies of the shortcut menu or function that the menu implements to
just handle the name of a table. Basically, the popup calls a function
(fnSelect) and passes it a value (-1, 0, or 1) which will determine whether a
field (IsSelected) in the table of interest is set to true, false, or is
inverted.
The challenge I'm having determining what table to use. I'd like to use
this same menu for three different forms (each using a separate table as its
RecordSource), all of which are either subforms, or sub-subforms. I wrongly
assumed that I could refer to the Screen.ActiveForm to identify the form that
the shortcut was activated from, but that did not work. I then tried
Screen.Activeform.ActiveControl, and got the control name of the subform that
was active, but that did not help for identfying the sub-subform. I'm stuck
at:
Public Function fnSelect(OptionValue as integer) as boolean
Dim TableName as string
Dim strSQL as string
'Need a way to determine which sub or sub-sub form the
'shortcut menu was activiated from. This worked for a
'sub-form, but not for a sub-sub form
Select Case Screen.Activeform.ActiveControl
Case "frm_1"
TableName = "tbl_1"
Case "frm_2"
TableName = "tbl_2"
Case "frm_3"
TableName = "tbl_3"
Case Else
Goto SelectError
End Select
strSQL = "UPDATE [" & TableName & "] " _
& "SET [IsSelected] = " & iif(OptionValue = 1, _
" NOT
[isSelected]", _
OptionValue) & " " _
& "WHERE [Act_ID] = " & Forms("frm_Activities").txt_Act_ID
Currentdb.execute strsql, dbFailOnError
'Insert a line here to requery the appropriate sub or sub-sub form
SelectExit:
fnSelect = true
Exit Function
SelectError:
msgbox "Error updating IsSelected in table '" & TableName & "'"
fnSelect = false
End Function
Would appreciate any help I can get. Thanks.