Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Default to todays date on VB calendar

Posted on 2015-02-04
15
Medium Priority
?
63 Views
Last Modified: 2015-02-06
Private Sub Calendar1_Click()
TxtDate.Text = Calendar1.Value
End Sub

I am using this code for a calendar but I would like it to default to todays date
0
Comment
Question by:bjfulkerson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
15 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40589381
If you want the textbox to have today's date just do

TxtDate.Text = Now()
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40589385
And if you want the calendar to show today then

Calendar1.Value = Now()
0
 

Author Comment

by:bjfulkerson
ID: 40589447
Neither of these worked

Private Sub Calendar1_Click()
'TxtDate.Text = Calendar1.Value
'Calendar1.Value = Now()
TxtDate.Text = Now()
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:bjfulkerson
ID: 40589513
I still need to change the date when I select it on the calendar.  These won't let me.  

I also need to have any data in this text box to clear after the add key is selected

Private Sub TxtA_Change()

End Sub
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40589525
Can you attach your workbook and post a detailed explanation of what you are trying to do?
0
 

Author Comment

by:bjfulkerson
ID: 40589533
Let me finish my work and I will upload it soon
0
 

Author Comment

by:bjfulkerson
ID: 40591098
I have uploaded my workbook and a word doc with explanation.

Thanks in advance.
This-is-a-timesheet-entry-and-employee-u
StlFunction-Analisys-2015-v1c.xlsm
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40591177
I'm sorry but the workbook is too big for me to open. Here are some common ways to make it smaller. Or perhaps you could copy it and cut the copy down to just the parts that are needed to demonstrate the problem.
0
 

Author Comment

by:bjfulkerson
ID: 40591940
Martin
It is much smaller now.
The Vlookup and the UPH calculation are no being carried down to the next ROW with a new entry
Thanks in advance
StlFunction-Analisys-2015-v1c.xlsm
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40592236
Yes, that's much better:) I'll take a look at it and get back to you as soon as I can.
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40592263
Your "explanation" document unpacked into some xml, etc files. Can you explain here what you expect to have happen?
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40592273
Wait, if all you want to do is to have the calendar show today's date when the form opens then you had the Calendar1.Value = Now() line in the wrong place. Move it to the UserForm_Initialize() sub.
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40593651
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 

Author Comment

by:bjfulkerson
ID: 40593655
This is a timesheet entry and employee update doc to track productivity.

1.      I would like the cursor to start in the INITIALS box.  Currently, when the initials are entered it auto pops the FNAME, LNAME, STATUS and HDEPT.
a.      I would like the cursor to jump to the FUNCTION CODE box and using the tab to the A#, TIME, UNITS, ADD button.
b.      After pressing enter when the ADD button is active, can the A# box be cleared?
2.      All this data updates the Timesheet Tab
a.      When I ADD, I get an error
 Runtime error 424
the debugger highlights     .Cells(lastrow + 1, "G").Value = TxtUPH.Text


Private Sub ccmdAdd_Click()
   Dim lastrow As Long
   
   With Sheets("Timesheet")
     lastrow = .Range("A1048576").End(xlUp).Row
    'lastrow = Sheets("Timesheet").Range("A2").End(xlDown).Row
    .Cells(lastrow + 1, "A").Value = ComboBox1.Text
    .Cells(lastrow + 1, "B").Value = TxtDate.Text
    .Cells(lastrow + 1, "C").Value = CB2FunctionCode.Text
    .Cells(lastrow + 1, "D").Value = TxtA.Text
    .Cells(lastrow + 1, "E").Value = TxtTime.Text
    .Cells(lastrow + 1, "F").Value = TxtUnits.Text
    .Cells(lastrow + 1, "G").Value = TxtUPH.Text
    .Cells(lastrow + 1, "H").Value = TxtFname.Text
    .Cells(lastrow + 1, "I").Value = TxtLName.Text
    .Cells(lastrow + 1, "J").Value = TxtHDept.Text
   
   End With
 
 End Sub
 
b.      When I enter a new line item through the TIME SHEET ENRTY it removes the functions that are in place.  I have a VLOOKUP function in the DESCRIPTION column to add the description by the code entered and in UNITSperHR.  It doesn’t update the rest of the information LNAME, FNAME and HDEPT.  See row 35 and 36 for example.
Thanks for your time

Jody
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40593767
I'll be happy to help but this should be a new question.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question