Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Type mismatch error

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Type mismatch error

Is 'lFacilRowsUI' text or Value? If it is Value, I think if it is Text, you
need something like this:
"'" Or lFacilRowsUI = "'"
That is a apostrophe between the quotes.
If it is Value, i think you need something like this:
" Or lFacilRowsUI = "

HTH,
Ryan---
--
RyGuy


"salgud" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Type mismatch error

If they are both textboxes, then you access the Text property of both:

Sub UserInputCheck()
frmFacil.Hide
sFacilNameUI = frmFacil.tbFacilName.Text
On Error Resume Next
lFacilRowsUI = frmFacil.tbFacilRows.Text
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

If you want to ensure that the number of clients is a positive number (for
example), try this:


Sub UserInputCheck()
frmFacil.Hide
sFacilNameUI = frmFacil.tbFacilName.Text
On Error Resume Next
sFacilRowsUI = frmFacil.tbFacilRows.Text
if IsNumeric(sFacilRowsUI) then lFacilRowsUI=CInt(lFacilRowsUI) else
lFacilRowsUI=0
On Error GoTo 0
If (sFacilNameUI = "") Or (lFacilRowsUI < 1) 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

"salgud" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Type mismatch error

On Tue, 10 Mar 2009 13:11:01 -0700, ryguy7272 wrote:

Is 'lFacilRowsUI' text or Value? If it is Value, I think if it is Text, you
need something like this:
"'" Or lFacilRowsUI = "'"
That is a apostrophe between the quotes.
If it is Value, i think you need something like this:
" Or lFacilRowsUI = "

HTH,
Ryan---


Thanks for your reply, Ryan, but it doesn't make much sense. "If it is
Vaue, I think if it is Text" confuses me. And the quotes in my post are not
around "or lFacilRowsUI", they indicate testing for blank values in either
field, as in sFacilNameUI = "" and lFacilRowsUI = "".

BTW, I should have said that lFacilRowsUI is long, and sFacilNameUI is a
string. Does anyone have any other suggestions?
  #5   Report Post  
Posted to microsoft.public.excel.programming
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?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Type mismatch error

On Tue, 10 Mar 2009 13:57:52 -0700, Tim Zych wrote:

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


Thanks, Tim!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"