Consulting

Results 1 to 7 of 7

Thread: Have a Label/Command Button Run a Spin Button (cross posted)

  1. #1

    Have a Label/Command Button Run a Spin Button (cross posted)

    I have a userform that has a Spin Button in it, and I am trying to hit a Command Button (or Label in this case) and make it run the SpinDown and then Another to run the SpinUp, but this doesn't appear to work.

    Is this not possible?

    My Spin Buttons look like this:
    Public Sub SpinButton1_SpinDown()
    'SCAN FORWARD
    ShowCurrentRecord
    With New MSForms.DataObject
         .SetText TextBox1.Text
         .PutInClipboard
    End With
    End Sub
    
    
    Public Sub SpinButton1_SpinUp()
    'SCAN BACKWARD
    ShowCurrentRecord
    With New MSForms.DataObject
         .SetText TextBox1.Text
         .PutInClipboard
    End With
    End Sub
    I tried this:
    Private Sub Label14_Click()
    SpinButton1_SpinDown
    End Sub
    and

    Private Sub Label14_Click()
    UserForm1.SpinButton1_SpinDown
    End Sub

    Thanks in advance for any help.


    (Of you need the reasoning behind this, it is so I can use better visuals for my Spin buttons than the default ugly ones)

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome to VBAX.

    please post a link to your thread in other forums. when your post count is 5 you can paste links.

    until then you can provide the link by insertind spaces before and after dots like:

    http:// www . vbaexpress . com/ forum/showthread.php?51816-Have-a-Label-Command-Button-Run-a-Spin-Button-(cross-posted)
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    are they on the same userform?

    if not:
    Public Sub Label14_Click()
    UserForm1.SpinButton1_SpinDown
    End Sub
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Quote Originally Posted by mancubus View Post
    are they on the same userform?

    if not:
    Public Sub Label14_Click()
    UserForm1.SpinButton1_SpinDown
    End Sub
    They are on the same userform and I tried the above (I think it's what I posted up above) but it errors.

    Edit:
    Yes that is what I tried and it seems to do nothing when I click them. (no error, just no result)

  5. #5
    Was solved via other thread
    Private Sub Label13_Click()
        If SpinButton1.Value - 1 >= SpinButton1.Min Then
            SpinButton1.Value = SpinButton1.Value - 1
            SpinButton1_SpinDown
        End If
    End Sub
    
    Private Sub Label14_Click()
        If SpinButton1.Value + 1 <= SpinButton1.Max Then
            SpinButton1.Value = SpinButton1.Value + 1
            SpinButton1_SpinUp
        End If
    End Sub

  6. #6
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Quote Originally Posted by NewYears1978 View Post
    They are on the same userform and I tried the above (I think it's what I posted up above) but it errors.

    Edit:
    Yes that is what I tried and it seems to do nothing when I click them. (no error, just no result)
    they are not indeed: Private vs Public
    Public worked for me when i tested.

    please mark the thread as solved for future references...
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  7. #7
    Quote Originally Posted by mancubus View Post
    they are not indeed: Private vs Public
    Public worked for me when i tested.

    please mark the thread as solved for future references...
    Done and thank you

Posting Permissions

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