if statement

  • Thread starter Thread starter Taher
  • Start date Start date
T

Taher

Hi there

I have a form which has option boxes. And there are
several combo boxes. But i want to write a code which if
the option value is 1 and the combo box is null it gives a
msg.
But when option is 2 and the combo box is null it does not
give any message.

Also when option is 1 and combo box is not null it does
not give any message.

I tried to work on the code but its not working. Below is
the code

Private Sub Command149_Click()
On Error GoTo Err_Command149_Click

Dim msg, style, Mycheck, checkcriteria, response,
Mystring, style1, checkcriteria1, Mycheck1
Dim varEnteredvalue As Variant
msg = "Please enter Approver's Name!"
style = vbYesNo + vbExclamation
Msg1 = " Did you enter Approvers name!"
style = vbYesNo + vbExclamation

'checkcriteria = Forms![PROGRAM SIGN OFF]![PROGRAM SIGN
OFF Subform].Form!Frame23
checkcriteria = Forms![PROGRAM SIGN OFF]![PROGRAM SIGN
OFF Subform].Form!S_Name

Mycheck = IsNull(checkcriteria)
If varEnteredvalue = "1" And Mycheck = True Then
MsgBox msg, style
End If

Mycheck = IsNull(checkcriteria)
If varEnteredvalue = "2" And Mycheck = IsNull
(checkcriteria) Then
DoCmd.Close
End If

Mycheck = IsNull(checkcriteria)
If varEnteredvalue = "1" And Mycheck = False Then
DoCmd.Close
End If



Exit_Command149_Click:
Exit Sub

Err_Command149_Click:
MsgBox Err.Description
Resume Exit_Command149_Click

End Sub

I would appreciate if somebody can help resolve this issue.

Thank you.
 
if
the option value is 1 and the combo box is null it gives a
msg.
But when option is 2 and the combo box is null it does not
give any message.

Also when option is 1 and combo box is not null it does
not give any message.

if opt.Value = 1
if IsNull(cbo) Then
msgBox "Can't be empty when it's one"

else
' no message

end if

elseif opt.Value = 2
if IsNull(cbo) Then
' no message

else
' no information given for this

End if

else ' opt neither 1 nor 2
msgbox "System error in opt value"

end if


Hope that helps


Tim F
 
Back
Top