Case select

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
 
D

Dirk Goldgar

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
 

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