TextBox Entry

Smurfit-Stone

Active Member
Joined
Dec 1, 2004
Messages
485
Hello Board,

I have a textbox on a form to enter a date, along with some other textboxes for other data. There are hundreds of records entered into this form daily. I'd like to know if there is a way I could have the date in this textbox remain whenever I enter the first record and change only when I enter another day's date. I'm trying to eliminate entering the date everytime for each daily record. Thanks in advance.
 
Hi Smurfit-Stone,

A "Tag" is the Tag property of a control. If you check out the Properties of any control (eg a text box) and go to the Data tab of the properties, you will see Tag. It's a general-purpose property that can hold data, and you can use that data and change it. The post that I referenced gives an idea of how to use them.

Denis
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hey Denis, I check out the link you suggested and then I tried the code. It works perfectly. I had to make a few changes on my query and form, but I love the fact that the date remains until I change it.......Thanks so much!
 
Upvote 0
MyBoo
Thanks so much for your direction. Please understand that I'm not Access literate. I do comprehend some of your instruction....its the coding I can't do. I would greatly appreciate it if you could provide the steps and code I need to accomplish this magic. Thanks to all of you for your insight.

As I don't know what your form looks like, I need to make some assumptions here. They are:
You are using a form to enter your information.
The form is based on the table that stores this data.
You have a Date field... I'll call this TableDate.

Open your form in Design mode.
Right click your mouse pointer in the upper left corner of this form... in the little square box you see there. You should get a drop-down.
Left click on the Properties option. This opens the properties for the FORM.
In the properties window, you should see an Event tab. Click on this if it is not the active tab.
Find the On Open Event in the list.... move your mouse pointer just to the right of that line and click the left mouse button... you should see an elipse (...) Click once on this to display a popup.
In this popup, you should see an option for Code Builder... click once on this, then click on OK.
You should now see
Private Sub Form_Open(Cancel As Integer)

End Sub

Enter text as listed below
Private Sub Form_Open(Cancel As Integer)
Me!DefaultDate = Null
End Sub
(press the space bar 5 times before entering this line of code... to indent)

Click on File/Close and Return to Microsoft Access.

You should now be back in the form (design mode)
Click once on your Date field to select it.
In the properties window, click on the Format tab, find the Visible option and double click that line, to change it from Yes to No.
Click on the Other tab and write down the number that is listed in Tab Index... we will need this later.
Create another Text Field.
Click on the Other tab and change the Name option to DefaultDate
Click on the Data tab, then the Input Mask option and select the Date format you want to use.
Change the label of this new field... name it whatever you want to.
Click once in the DefaultDate field again, to select it.
Click the Event tab, select the On Lost Focus event and open the Code builder again.

Enter the following:

Me!TableDate = Me!DefaultDate

Click on File/Close and Return to Access again.
Click once on the new DefaultDate field to select it.
Click on the Other tab in the properties window. Write down the number that is listed in the Tab Index and then change that number to what you wrote down before.
Click on the original Date field.. to select it and change it's Tab Order number to that which you just wrote down.

Close your form and test.

What we did here is the following:

When you open the form originally. the first bit of code will set the DefaultDate to null.. (nothing - blanks it out). This is just in case it got saved when you closed the form... you don't want that.
We hide the actual Date field from view of the user.
When you enter a new record, it's assumed on my part that you enter data in each field and press the tab or enter key to move to the next field. When you get to the DefaultDate field, you will enter a date and press tab/enter to move to the next field. The second bit of code we created will copy the DefaultDate into the TableDate field(hidden) when you move off of that field, to the next. When you move to another blank record, the DefaultDate will display the same date as you entered in the previous record. When you tab through the fields, moving off of the DefaultDate, whatever is entered there will be copied to the original Date field.
The reason we changed the Tab Order should be obvious simply by the name. If we had not changed the order, you would find the tab order not to your liking.

What I gave you here is minimal but sufficient to get the job done properly. If you view previously entered records via this form, do not tab/enter through the fields as this will change the date to whatever is in the DefaultDate field at that time. If you have to do this, come back to this board and we can adjust the code.

Hope this helps!
I apologize if my explanation is too basic.
 
Upvote 0

Forum statistics

Threads
1,215,721
Messages
6,126,461
Members
449,315
Latest member
misterzim

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