Display Current Date On Form

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
I created a form. But when it opens, the first date from the table appears.

Is there a way where the current date could appear?

So today is 11/16/02 and this is what I would want to appear when the form is opened. Tommorrow 11/17/02. Any suggestions?

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Create a text box that is not based on a field in your underlying table (the table that the form is based on). This is called an Unbound control. In the Control Source field, put:

=Date()

That should do it - let us know if it does not.

-rh
 
Upvote 0
Hi Russell,

The thing is that the Date field is bound to a table. The dates in the table range from 11/1/02 through 12/31/03.

When the form opens, the first date appears 11/1/02. So the users would have to scroll to input data for the current date.

I want to eliminate the scrolling and have today's date be the record that appears when the form opens.

I am sure it can be done, I just don't know how to do it.

Thanks
 
Upvote 0
Do you want today's date to be recorded in your table, or do you just want it on the form? If you want today's date to be the value of a new record, set that field's default property to

=Date()

This is not a field named "Date" - notice the parentheses after Date.

-rh
 
Upvote 0
I'll try to make this as simple as possible.

I created a form.
There is a text box that is linked to a table. The table has a list of dates.

What I need is, when the form opens, to lookup the date values in the table and display today's date.

Example: I open the form today, the date in the text box will be 12/18/02. Tomorrow when I open the form it would look up the value 2/19/02.

Russell, the date value is being looked up from a table that it is linked to. I can't add "date()" because the date is a key field and it will not allow duplicates and I already have the date listed in there. I just need the current date displayed.

Thanks for your help and any suggestions.
 
Upvote 0
So you want to change the date in the table? Because if you want today's date in the text box that is linked to the table, it will change the value in the table. Like you said, it is linked to the table - so if the table's value is not today's date, then today's date will not be displayed.

If you don't want to change the dates in the table, then you will need to add an extra text box to the form.

Make sense? Maybe give some more info as to why you want to see today's date.

-rh
 
Upvote 0
Lets think of it as a drop down box. A drop down box gets the data it displays from a table. And you choose the data you want to view. Same thing here.

I have a text box that looks up its date value from a table. The date in the table are 11/1/02, 11/2/02 through 12/31/03.

There is more data associated to the row where the date is located. This data will be inputted manually through the form. And the key field is the date.

Right now if someone wants to input data, the form will open and they will need to scroll down from 11/1/02 till they reach today's date and then start entering the information.

What I want is to eliminate the scrolling and searching for the date. And have the form automatically open the form with the current date.

I hope I made sense.

Parra
 
Upvote 0
So is the form always opening to a new record? Anyway, you want a new record to have today's date, correct? If so, then open the table in Design view, click on the Date field, and at the bottom next to Default Value, put:

=Date()

That should do it!

Hope it helps,

Russell
 
Upvote 0
Sorry Russell but it is not a new record. It is not new because the date is already created, only data is being added to it.

There has to be a way to accomplish this.

Thanks for your help, Russell.
 
Upvote 0
So do you have a table that has only dates in it populating your ComboBox (or drop down, as you have described it)?

Ok, you can put code into the Current event of the form to say something like:

Me.ComboBox1.Text = Format(Date(),"mm/dd/yy")

I'm still not sure what you want to use this date for - if you could explain your ultimate goal, it would really help.

HTH,

Russell
 
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,152
Members
451,625
Latest member
sukhman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top