if statment

T

Taher

Hi Tim

Im sorry to post the last message as i thought that the
message was not clear. Also i tried to work with the
procedure you gave me but its no working. I really
appreciate you fast response. Below is the code

Private Sub Command149_Click()
On Error GoTo Err_Command149_Click

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


If optValue = 1 Then
If IsNull(Combo30) Then
MsgBox msg, style
Else
' no message

End If

ElseIf optValue = 2 Then
If IsNull(Combo30) 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


Exit_Command149_Click:
Exit Sub

Err_Command149_Click:
MsgBox Err.Description
Resume Exit_Command149_Click

End Sub

I appreciate you help.
Thank you.
 
T

Tim Ferguson


I assume this is me: _please_ keep answers and follow ups to one problem is
a single thread because it helps to avoid duplication and (worse!)
contradiction.
i tried to work with the
procedure you gave me but its no working. I really
appreciate you fast response.

What is not working? You did not give a lot of detail so I only provided a
general algorithm. Some comments interlaced:
Private Sub Command149_Click()

Having a control named Command149 is not doing yourself any favours. Do get
into the habit of naming everything according to what it is or does, such
as cmdCheckInput or whatever.
On Error GoTo Err_Command149_Click

Get rid of error suppression until you know that the rest of the function
is working as required.
Dim msg, style, Mycheck, checkcriteria, response,

Be warned that dimming values like this produce all Variants. It's much
better to use explicit datatypes and sensible names

Dim strEnterApproversName As String

(or for this you could actually use a Const)
If optValue = 1 Then

What exactly is optValue? Remember that option buttons have to belong to an
Option Group, and it's the group that has the .Value property, not the
individual buttons.
If IsNull(Combo30) Then

Depending on how your combo box works, the following sometimes works better
(and the same applies to naming it):

If Combo30.ListIndex < 0 Then ' nothing selected


A more explicit naming system and clearer objectives would probably help.
For example, what exactly are you trying to validate... would it be better
to use an AfterUpdate or LostFocus event?

Hope that helps


Tim F
 

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

Similar Threads

if statement 1
vba code 1
if statement 1
Changes in How Code Acts After Upgrade of Excel 2
if then msgbox 1
how to write VBA for DELETE RECORD? 2
Multiple VByesno Message boxes no working 2
SQL statment errors 2

Top