PDA

View Full Version : Solved: From - Option Button & Focus issue



Glaswegian
01-12-2007, 03:17 AM
Hello

Long time since I've been here, but I do need a bit of help.

I have a form that is used for collection of various pieces of data. The form opens as soon as the workbook does and the users do not see or have access to any sheets. Input to the form affects which further form then appears and so on. All this works well.

To ensure that users input to all the required fields, I'm using the Exit Event on each field (a mixture of Listboxes, Comboboxes and Textboxes) and again, this works fine, with a message advising the user to complete the field.

Where I have the problem is a frame with two option buttons. Users must select one button before moving to the next field. If they exit without completing, the message box appears, they click OK to clear that, but are then unable to select the first option button - they can only select the second button. So, if they fail to select either button, after the warning they must select the second button before they can select the first one. I can't work out why this would happen and would appreciate any help.

Private Sub frCustInfo_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If optNewCust = False And optExistCust = False Then
MsgBox "You must choose either 'New' or 'Existing' customer.", vbInformation, "Invalid Input - Customer Type"
Cancel = True
End If
frCustInfo.SetFocus
End Sub
The code seems fairly straightforward - the only thing I thought of was setting the focus to the frame, but even taking that line out doesn't help.

Thanks in advance.

Bob Phillips
01-12-2007, 03:30 AM
I could select either option button, so my guess is that there is some code behind those buttons that may be causing it. Can you post a workbook?

Glaswegian
01-12-2007, 04:10 AM
Hi xld

Sorry for the delay - had to change a few things before attaching a sample for you.

Thanks for your help.

Bob Phillips
01-12-2007, 05:35 AM
You have the same test in the optCustExist_Exit event. This is superfluous, so just ditch it.

Glaswegian
01-12-2007, 05:52 AM
*sigh* - why is it always the little things that get missed and then cause the problem?

Many thanks for your help - I'll mark this one Resolved.

Cheers!