Consulting

Results 1 to 8 of 8

Thread: Solved: GoTo in VBA

  1. #1
    VBAX Regular
    Joined
    May 2011
    Posts
    46
    Location

    Solved: GoTo in VBA

    Hello all,

    I try the following but it does not work. [error = "object required"]
    Can anyone tell me why?

    [VBA]
    If CheckBox1 = True And TextBox2.Value < texbox7.Value Then GoTo Option1

    If CheckBox1 = True And TextBox2.Value > TextBox7.Value And TextBox2.Value < TextBox7.Value + TextBox8.Value Then GoTo Option2

    If CheckBox1 = True And TextBox2.Value > TextBox7.Value + mytot3 + mytot2 Then GoTo Option3

    Option1:
    MsgBox ("Verlof")

    Option2:
    MsgBox ("Verlof & BW")

    Option3:
    MsgBox ("Verlof & BW & TVT")
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]If CheckBox1 = True And TextBox2.Value < texbox7.Value Then Goto Option1

    If CheckBox1 = True And TextBox2.Value > TextBox7.Value And _
    TextBox2.Value < (Val(TextBox7.Value) + Val(TextBox8.Value)) Then Goto Option2

    If CheckBox1 = True And TextBox2.Value > (Val(TextBox7.Value) + mytot3 + mytot2) Then Goto Option3

    Option1:
    MsgBox ("Verlof")

    Option2:
    MsgBox ("Verlof & BW")

    Option3:
    MsgBox ("Verlof & BW & TVT") [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    May 2011
    Posts
    46
    Location
    I am sorry, the error persists

  4. #4
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Quote Originally Posted by Ethan
    [error = "object required"]
    Can anyone tell me why?
    [vba]
    If CheckBox1 = True And TextBox2.Value < texbox7.Value Then GoTo Option1[/vba]
    Typo
    [vba]If CheckBox1 = True And TextBox2.Value < TextBox7.Value Then GoTo Option1[/vba]

    David


  5. #5
    VBAX Regular
    Joined
    May 2011
    Posts
    46
    Location
    what a fool I am
    Thanks guys.

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Try using Option Explicit at the top of your code, as it will pick up these sorts of issues
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    or
    [VBA]
    If CheckBox1 Then
    if TextBox2.Value < TextBox7.Value Then
    c01=""
    ElseIf TextBox2.Value > TextBox7.Value And TextBox2.Value < TextBox7.Value + TextBox8.Value Then
    c01= " & "BW"
    ElseIf TextBox2.Value > TextBox7.Value + mytot3 + mytot2 Then
    c01=" & BW & TVT"
    End If
    End If

    MsgBox "Verlof" & c01
    [/VBA]



  8. #8
    VBAX Regular
    Joined
    May 2011
    Posts
    46
    Location
    Thanks SNB!

Posting Permissions

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