Using SpinControl to update date value in a form
Using SpinControl to update date value in a form
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Using SpinControl to update date value in a form

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi,

    Does anyone know where to start with using Spinbuttons ?

    I want to use a spinbutton to change the day value in in a textbox that holds the current date. But have no idea where to start ! Any help would be great !

    Cheers
    Darren

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Howdy, I have a very similar thing going on at the moment. If you Private message me your email address, I'll send you a spin button that does the days of week

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Alternatively, just select spin button from the Control Toolbox toolbar, draw it on your page, then right click and go to Properties. In the field marked Linked Cell, put the cell rreference you want it to connect to (E.g: A2) then set Max Length to about 10,000,000 to give yourself plenty of range. Now close the Properties window and take yourself out of design mode. Now right click on the cell you linked to, and pick Format Cells.

    Go to the Number tab and choose Date from the menu, and pick the type of date format you want to use. Hey presto

  4. #4
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi Darren


    Paste this in the UserForm Private module, just change the names to suit.

    Option Explicit
    Dim dDate As Date

    Private Sub SpinButton1_SpinDown()
    dDate = DateValue(TextBox1.Value) - 1
    TextBox1 = Format(dDate, "dd mmm yyyy")
    End Sub

    Private Sub SpinButton1_SpinUp()
    dDate = DateValue(TextBox1.Value) + 1
    TextBox1 = Format(dDate, "dd mmm yyyy")
    End Sub

    Private Sub UserForm_Initialize()
    TextBox1 = Format(Date, "dd mmm yyyy")
    End Sub

    It would be a very good idea to set the "Locked" Property of TextBox1 to False while in the VBE.

    _________________
    Kind Regards
    Dave Hawley
    OzGrid Business Applications
    Microsoft Excel/VBA Training


    [ This Message was edited by: Dave Hawley on 2002-03-25 06:31 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com