Capturing events on a frame within a multi-page (tab) control

tfurnivall

Registered User.
Local time
Today, 01:08
Joined
Apr 19, 2012
Messages
81
I have a form with a tab control and an option group (frame).
When I built the layout of the contents of the first tab, the frame responded properly to click events. Now that I have copied them onto the tab control, the events seem to disappear.

(When I check the events for the controls, they are all still there, and selected by the Properties table).

I know it's probably one of the "doesn't use Access very much, does he" type of situations, so I'll confess my naivete, and simply ask for any ideas to get these controls working again!

Here is the Form Code listing. You'll notice it's very early on in the development process! I'm also away from home with no manuals:(
Code:
Option Compare Database
Option Explicit

Sub SetSourceDescription()

If Me.frRunMode.Value = 0 Then
   Me.lblSourceType.Caption = "Source for this run will be the Extract .pst file(s)"
ElseIf Me.frRunMode.Value = 1 Then
   Me.lblSourceType.Caption = "Source for this run will be the Messages table"
End If

End Sub


Private Sub cmdBrowseContentFile_Click()

'   Put up an OpenFile dialog, and get the name of the Content file.
MsgBox "Browse for the Content Term file"

End Sub

Private Sub cmdBrowseLocationFile_Click()

'   Put up an OpenFile dialog, and get the name of the Location file.
MsgBox "Browse for the Location file"

End Sub

Private Sub cmdBrowseParticipantFile_Click()

'   Put up an OpenFile dialog, and get the name of the Participant file.
MsgBox "Browse for the Participant file"

End Sub

Private Sub cmdDone_Click()

'   Run the CalculateRelevancy Scores
'   Form stays open, and is updated periodically.

MsgBox "Run the RelevancyCalculation process, using the appropriate source"

End Sub

Private Sub cmdExit_Click()

'   Exit without running the Relevancy Score calculations

MsgBox "Exit without running the Relevancy Calculation"

End Sub

Private Sub Form_Load()

Me.frRunMode.Value = 0
Me.SetSourceDescription

End Sub

Private Sub frRunMode_Click()

Me.SetSourceDescription

End Sub

Private Sub optBuildMode_Click()

'   Set the Source to be the Extract of Email messages. Clear any tables in the database

Me.lblSourceType.Caption = "Source for this run will be the Extract .pst file(s)"
'Me.optReCalculateMode.Value = False

End Sub

Private Sub optReCalculateMode_Click()

'   Set the source to be the Messages table in the database. No extract files are needed

Me.lblSourceType.Caption = "Source for this run will be the Messages table in the database"
'Me.optBuildMode.Value = False

End Sub
Any suggestions appreciated!

Tony
 
To handle the Click event of a button you need to set the OnClick property of the button to "[Event Procedure]," and write a handler for the event, something like . . .
Code:
Private Sub cmdTest_Click()
  MsgBox "foo"
End Sub
What happens with tabs is that if you ever cut the button from one tab and paste it to another the OnClick property, normally "[Event Procedure]" sometimes gets erased. Make sure that is present . . .
 
An option group normally has a value (depending on which option is active) and that is the value which is used in code. That value is normally an integer. You seem to dive into each individual option within the optiongroup. Is that so?

If you copy controls in one tab page and paste them into another, you are still on the same form, so the pasted controls now have new names, but there is no automatic copy/renaming of event handlers.
 
Problem solved - thanks to all!

It was a combination of cutting and pasting within the form! It seems that any cut-and-paste from one container (form.detail) to another (form.detail.frame1) 'loses' the connection between the control and the handler. The fix was laughably simple:

Simply click on the OnClick event handler for the control in the new location, and select code builder. VBA seems to rediscover the original code, and restore the linkages to it. (At any rate, that's the tentative working theory - all I'm really concerned about is that it now works ;))

Apologies to spikepl about the confusing remnants of code for the option buttons. Too much Excel programming!

Problem solved, thanks for this wonderful community.

Tony

PS Check elsewhere for the current problem!
 

Users who are viewing this thread

Back
Top Bottom