Trouble with Focus-Subform to MainForm

J

Jim Ory

WinXP and Access2K2

Available References:

Visual Basic For Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Library

First, thanks to all that have helped me here in this discussion group. From
the non-MVPs to the most excellent MVPs. You are all a great source of
knowledge and I appreciate your time and effort to help all of us.

I have an unusual problem (aren't they all?). My main form, "AddEditEntity"
has 11 subforms under TAB control. These subforms, in short are addresses,
volunteer times, services rendered, etc.

In the subform "frmVolTimes subform", I have checkboxes, one for each day of
the week, that when checked means that a person is not available for
volunteer work on that day. Wait there's more. When the check box has been
checked, in the "After Update" event, the following code runs.

Private Sub ysnNoSun_AfterUpdate()
On Error GoTo ProcError
If Me.ysnNoSun = True Then
Me.txtSunLabel = "Sun"
Me.strSunPer.SetFocus
ElseIf Me.ysnNoSun = False Then
Me.strSunPer = Null
Me.txtSunLabel = Null
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

The control "strSunPer" is a combo box where one could select one of four
items: AM, PM, Eve, or ALL. If the data entry person exits the control
without entering from the combo box, then this runs:

Private Sub strSunPer_Exit(Cancel As Integer)
On Error GoTo ProcError
If Me.ysnNoSun = True And IsNull([strSunPer]) Then
MsgBox "Enter a time period from drop down menu . . .", vbInformation,
"Sunday Time Period"
Me.strSunPer.SetFocus
Cancel = True
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

If data entry started at the strSunPer and the checkbox was not checked,
then this code runs:

Private Sub strSunPer_Enter()
On Error GoTo ProcError
If Me.ysnNoSun = False Then
MsgBox "Please place a check in 'No Sun' check box", vbInformation,
"Sunday Time Period"
Me.ysnNoSun.SetFocus
Else
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

All works just fine and fills the need I have for a directory listing for
the volunteer group. Although there may be some redundancy in my methods, I
can clean that up later.

Now, the problem, and this is not serious, but, after completing entries on
the subform, if a control is clicked on the main form and then on to the next
record, this warning appears: "Please place a check in 'No Sun' check box.
(Or whatever was the last combo box control related to a day of the week on
the subform.) I'm only taking a guess here that the focus stayed on the
subform, on the "strSunPer" control for the next record and because there was
an "Enter event" to that control when the record changed, the warning message
came up. Clicking the OK on the warning message clears the message and the
new record appears. No damage, but annoying.

Thanks in advance for your thoughts.
 
P

Pieter Wijnen

try setting the focus to another control in the main forms current event
I think that might solve it

Pieter


Jim Ory said:
WinXP and Access2K2

Available References:

Visual Basic For Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Library

First, thanks to all that have helped me here in this discussion group.
From
the non-MVPs to the most excellent MVPs. You are all a great source of
knowledge and I appreciate your time and effort to help all of us.

I have an unusual problem (aren't they all?). My main form,
"AddEditEntity"
has 11 subforms under TAB control. These subforms, in short are addresses,
volunteer times, services rendered, etc.

In the subform "frmVolTimes subform", I have checkboxes, one for each day
of
the week, that when checked means that a person is not available for
volunteer work on that day. Wait there's more. When the check box has been
checked, in the "After Update" event, the following code runs.

Private Sub ysnNoSun_AfterUpdate()
On Error GoTo ProcError
If Me.ysnNoSun = True Then
Me.txtSunLabel = "Sun"
Me.strSunPer.SetFocus
ElseIf Me.ysnNoSun = False Then
Me.strSunPer = Null
Me.txtSunLabel = Null
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

The control "strSunPer" is a combo box where one could select one of four
items: AM, PM, Eve, or ALL. If the data entry person exits the control
without entering from the combo box, then this runs:

Private Sub strSunPer_Exit(Cancel As Integer)
On Error GoTo ProcError
If Me.ysnNoSun = True And IsNull([strSunPer]) Then
MsgBox "Enter a time period from drop down menu . . .", vbInformation,
"Sunday Time Period"
Me.strSunPer.SetFocus
Cancel = True
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

If data entry started at the strSunPer and the checkbox was not checked,
then this code runs:

Private Sub strSunPer_Enter()
On Error GoTo ProcError
If Me.ysnNoSun = False Then
MsgBox "Please place a check in 'No Sun' check box", vbInformation,
"Sunday Time Period"
Me.ysnNoSun.SetFocus
Else
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

All works just fine and fills the need I have for a directory listing for
the volunteer group. Although there may be some redundancy in my methods,
I
can clean that up later.

Now, the problem, and this is not serious, but, after completing entries
on
the subform, if a control is clicked on the main form and then on to the
next
record, this warning appears: "Please place a check in 'No Sun' check box.
(Or whatever was the last combo box control related to a day of the week
on
the subform.) I'm only taking a guess here that the focus stayed on the
subform, on the "strSunPer" control for the next record and because there
was
an "Enter event" to that control when the record changed, the warning
message
came up. Clicking the OK on the warning message clears the message and the
new record appears. No damage, but annoying.

Thanks in advance for your thoughts.
 
O

oooo

yyyuiuiop;;'''


';';;lllkhbfcc b njmretyujkl;
Jim Ory said:
WinXP and Access2K2

Available References:

Visual Basic For Applications
Microsoft Access 10.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Library

First, thanks to all that have helped me here in this discussion group.
From
the non-MVPs to the most excellent MVPs. You are all a great source of
knowledge and I appreciate your time and effort to help all of us.

I have an unusual problem (aren't they all?). My main form,
"AddEditEntity"
has 11 subforms under TAB control. These subforms, in short are addresses,
volunteer times, services rendered, etc.

In the subform "frmVolTimes subform", I have checkboxes, one for each day
of
the week, that when checked means that a person is not available for
volunteer work on that day. Wait there's more. When the check box has been
checked, in the "After Update" event, the following code runs.

Private Sub ysnNoSun_AfterUpdate()
On Error GoTo ProcError
If Me.ysnNoSun = True Then
Me.txtSunLabel = "Sun"
Me.strSunPer.SetFocus
ElseIf Me.ysnNoSun = False Then
Me.strSunPer = Null
Me.txtSunLabel = Null
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

The control "strSunPer" is a combo box where one could select one of four
items: AM, PM, Eve, or ALL. If the data entry person exits the control
without entering from the combo box, then this runs:

Private Sub strSunPer_Exit(Cancel As Integer)
On Error GoTo ProcError
If Me.ysnNoSun = True And IsNull([strSunPer]) Then
MsgBox "Enter a time period from drop down menu . . .", vbInformation,
"Sunday Time Period"
Me.strSunPer.SetFocus
Cancel = True
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

If data entry started at the strSunPer and the checkbox was not checked,
then this code runs:

Private Sub strSunPer_Enter()
On Error GoTo ProcError
If Me.ysnNoSun = False Then
MsgBox "Please place a check in 'No Sun' check box", vbInformation,
"Sunday Time Period"
Me.ysnNoSun.SetFocus
Else
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

All works just fine and fills the need I have for a directory listing for
the volunteer group. Although there may be some redundancy in my methods,
I
can clean that up later.

Now, the problem, and this is not serious, but, after completing entries
on
the subform, if a control is clicked on the main form and then on to the
next
record, this warning appears: "Please place a check in 'No Sun' check box.
(Or whatever was the last combo box control related to a day of the week
on
the subform.) I'm only taking a guess here that the focus stayed on the
subform, on the "strSunPer" control for the next record and because there
was
an "Enter event" to that control when the record changed, the warning
message
came up. Clicking the OK on the warning message clears the message and the
new record appears. No damage, but annoying.

Thanks in advance for your thoughts.
 

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