Type mismatch error

P

Petr

Hallo,
I have the problem with numeric input via inputbox used in file path.
E.g.
… \Rok 2004 (GFS 1986 data)\SR\SR 2004 Q data.xls (numeric parameter
in this sample is "2004", respectively).


These are my 2 routines (for second I tried the workaround posted in
groups), but neither of them is working.
Thanks a lot in advance for any suggestions.
Best regards, Petr Duzbaba

Sub test_mismatch_error1()


Dim SegmInput As String
Dim YearInput As Integer


Application.ScreenUpdating = False

Do:
SegmInput = InputBox("Submit the correct abbreviation (SR)!")

If Not SegmInput = "SR" Then
MsgBox "Invalid input (must be SR)!", vbCritical
End If

Loop Until SegmInput = "SR"

segment_dbvr = SegmInput

Do:
YearInput = InputBox("Submit year!")

If Not YearInput = 2004 Then
MsgBox " Invalid input (must be 2004)!", vbCritical
End If

Loop Until YearInput = 2004


year_dbvr = YearInput


Workbooks.Open Filename:= _
"C:\Dokumenty\Prace\Verejne rozpocty\Ostatni VR\DB VR\Ctvrtletni
data\Rok " & year_dbvr & " (GFS 1986 data)" \ " & segment_dbvr & " \
segment_dbvr & " " & year_dbvr & " Q data.xls"""

End Sub


Sub test_mismatch_error2()
Dim segment_dbvr As String

Application.ScreenUpdating = False


Do:
SegmInput = Application.InputBox("Submit correct abbrev. (SR)")

If Not SegmInput = "SR" Then
MsgBox "Invalid input (must be SR)!", vbCritical
End If


Loop Until SegmInput = "SR"


Dim year_dbvr As Integer
Dim year_dbvr_aux As String

year_dbvr_aux = InputBox("Submit year:", "Year input")
If IsNumeric(year_dbvr_aux) Then
year_dbvr = year_dbvr_aux

Workbooks.Open Filename:= _
"C:\Dokumenty\Prace\Verejne rozpocty\Ostatni VR\DB VR\Ctvrtletni
data\Rok " & year_dbvr & " (GFS 1986 data)" \ " & segment_dbvr & " \
segment_dbvr & " " & year_dbvr & " Q data.xls"""


Else

End If

End Sub
 
T

Tom Ogilvy

What is this supposed to do:

" Q data.xls"""

It would produce


Q data.xls"


Why do you query the user for information you already know? just want to
smack'em around a little?
 
P

Petr

Dear Tom,
you are right that the double "" at the end of " Q data.xls""" could
be omitted, be sure that I am trying to help myself and use the past
users experiences from groups as much as possible, but even if I
remove the "" at the end the runtime error type mismatch error is
still occuring.
Best regards,
Petr Duzbaba
 

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