View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Type mismatch error

Is lFacilRowsUI declared as a Long?

If so evaluating it as a string will cause that error.

If lFacilRowsUI has not been assigned a value, it will default to 0 if
declared as a Long.

One way to fix it:

If sFacilNameUI = "" Or lFacilRowsUI = 0

But if 0 is an acceptable entry another approach is needed such as:

If frmFacil.tbFacilName.Text = "" And frmFacil.tbFacilRows.Text = "" Then
MsgBox "Please enter a both a Facility ...."
'...
End If

--
Tim Zych
http://www.higherdata.com
Workbook Compare - free and pro versions

"salgud" wrote in message
.. .
The following code tests if the user has input both pieces of data before
proceding with the program. But I'm getting a Type Mismatch error on the
IF
test.

Sub UserInputCheck()
frmFacil.Hide
sFacilNameUI = frmFacil.tbFacilName.Text
On Error Resume Next
lFacilRowsUI = frmFacil.tbFacilRows.Value
On Error GoTo 0
If sFacilNameUI = "" Or lFacilRowsUI = "" Then <------TYPE MISMATCH ERROR
MsgBox "Please enter a both a Facility Name and" & Chr(10) & _
"the number of clients served!", vbOKOnly
Call GetFacilName
End If

End Sub

How do I test for no entry on the lFacilRowsUI variable?