+ Reply to Thread
Results 1 to 3 of 3

Type mismatch error

  1. #1
    Petr
    Guest

    Type mismatch error

    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

  2. #2
    Tom Ogilvy
    Guest

    Re: Type mismatch error

    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?

    --
    Regards,
    Tom Ogilvy


    "Petr" <petr.duzbaba@click.cz> wrote in message
    news:ff6505d1.0502090507.1261f9e3@posting.google.com...
    > 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




  3. #3
    Petr
    Guest

    Re: Type mismatch error

    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




    "Tom Ogilvy" <twogilvy@msn.com> wrote in message news:<ecStVsqDFHA.2232@TK2MSFTNGP14.phx.gbl>...
    > 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?
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Petr" <petr.duzbaba@click.cz> wrote in message
    > news:ff6505d1.0502090507.1261f9e3@posting.google.com...
    > > 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1