We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Adding a default todays date to VB Excel Form

I would like as the heading says lol add a default value of todays date

Private Sub txtdate_Change()

End Sub


I've tried =date()

What is it?
Help me to help you :santa2:

Comments

  • Try....

    =now()

    and then format the cell to whichever date format you prefer.

    HTH.

    Mr_F.
  • Thanks but it isn't that.... this is for the visual basic program form.

    I think it needs something fancy nothing that something simple would do it lol

    Cheers anyway
    Help me to help you :santa2:
  • tomstickland
    tomstickland Posts: 19,538 Forumite
    10,000 Posts Combo Breaker
    textbox.text=date(date_format) I guess. VB help not installed on my home machine so I'll have to check at work tomorrow.
    Look in VB help.
    Happy chappy
  • Private Sub UserForm_Initialize()
    txtDate.Text = Date
    End Sub
  • Once again, you do it again!

    lol Cheers guys... although another quick prob no big deal ...

    My users need to click on the add button once (which enters all the info except the customer number) and twice for the customer number.

    I want a one click does it all

    That includes a clear function to show the user it has been entered in .. CHEERS :beer:
    Help me to help you :santa2:
  • tomstickland
    tomstickland Posts: 19,538 Forumite
    10,000 Posts Combo Breaker
    What add button methods are listed then?
    ie: Add_Button_Click

    Putting in break points by clicking on the left hand side of the code window can help you see whats happening.
    Happy chappy
  • That includes a clear function to show the user it has been entered in
    That was answered in your other thread.

    Put

    txtpet.text = ""
    txtqty.text = ""

    etc.

    after the statements which transfer the textbox values.
  • I tired adding it

    Private Sub cmdAdd_click_Click()

    'Declare variable intNext as an integar'
    Dim intNext As Integer

    'Set the value of intNext to be the number of rows in Dataset'
    intNext = Range("Dataset").Rows.Count + 1

    'Transfer the values in the form into the spreadsheet'
    Range("A" & intNext) = txtNumber.Value
    Range("B" & intNext) = txtpet.Value
    Range("C" & intNext) = txtqty.Value
    Range("D" & intNext) = txtprice.Value
    Range("E" & intNext) = txtstaff.Value
    Range("F" & intNext) = Txtname.Value
    Range("G" & intNext) = txtAddress.Value
    Range("H" & intNext) = txtphone.Value
    Range("I" & intNext) = txtdate.Value
    Range("J" & intNext) = txtcomments.Value

    'Runs the nextNumber procedure to display the next available number'
    Call NextNumber

    'Move the cursor to txttitle'
    txtpet.SetFocus

    End Sub


    I added it under the Range("J" & intNext) = txtcomments.Value
    txtnumber.text = ""
    txtpet.text = ""

    etc but it doesn't accept it .. .any ideas?
    Help me to help you :santa2:
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.5K Banking & Borrowing
  • 253.7K Reduce Debt & Boost Income
  • 454.5K Spending & Discounts
  • 245.5K Work, Benefits & Business
  • 601.4K Mortgages, Homes & Bills
  • 177.6K Life & Family
  • 259.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.