Case select

  • Thread starter Thread starter SoggyCashew
  • Start date Start date
S

SoggyCashew

Hello, I have a form named frmCalendar that has a option group. When I select
a option from the option group and click a button a password form opens and
in this form im using the code below to select the case from frmCalendar and
whatever case is selected then it opens that form asociated with that case.
My question is what can I put in the code so if one of the cases arent
selected <> then it would close the frmPassword form and set focus to the
option group on my frmCalendar.

With Forms!frmCalendar

Select Case !optEmpOrDept

Case !chkEmployee.OptionValue
DoCmd.OpenForm "frmEmployeeStatusChange"
DoCmd.Close acForm, "frmPasswordRequired"

Case !chkDepartment.OptionValue
DoCmd.OpenForm "frmDepartment"
DoCmd.Close acForm, "frmPasswordRequired"
Case Else


End Select
 
SoggyCashew said:
Hello, I have a form named frmCalendar that has a option group. When I
select
a option from the option group and click a button a password form opens
and
in this form im using the code below to select the case from frmCalendar
and
whatever case is selected then it opens that form asociated with that
case.
My question is what can I put in the code so if one of the cases arent
selected <> then it would close the frmPassword form and set focus to the
option group on my frmCalendar.

With Forms!frmCalendar

Select Case !optEmpOrDept

Case !chkEmployee.OptionValue
DoCmd.OpenForm "frmEmployeeStatusChange"
DoCmd.Close acForm, "frmPasswordRequired"

Case !chkDepartment.OptionValue
DoCmd.OpenForm "frmDepartment"
DoCmd.Close acForm, "frmPasswordRequired"
Case Else


End Select


That's what the "Case Else" clause is for, Chad. See it in the code you
posted? It's currently empty, but you could do this with it:

Case Else
' Set the focus on the option group on frmCalendar
.SetFocus
' Close this form, without any "save" prompt
DoCmd.Close acForm, Me.Name, acSaveNo
 
Back
Top