Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Text Box to Keep Previous Value

Status
Not open for further replies.

gmillerinc

IS-IT--Management
Aug 27, 2003
28
US
I would llike to enter in a date into a text box control on a form. The form's data is dumped into an underlying table. Is there anyway I can enter in a date in the text box and go to the next record and have the same date appear as a default (unless manually changed).
 
Try using the AfterUpdate property of the date field and set the default property for that field equal to what you just entered...

Me![DateField].Default = Me![DateField].Value

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
I tried that already. I put this code in the AfterUpdate event of the textbox (that I put the date in). However, I didn't put anything in for Default Value the Text Box in the Data tab (of the control's propertiess)...should I?

Here is the code for the AfterUpdate event for the textbox control:
Option Compare Database

Private Sub TaskDate_AfterUpdate()

Me![TaskDate].DefaultValue = Me![TaskDate].Value
End Sub

By the way, it must be say DefaultValue and not Default.

But when I enter in a date and I go to the next record in the form, the textbox says: 12/30/1899, when I want it to be the date I entered before going to the next record in the form.

Any ideas?
 
Well, 12/30/1899 tells me that the date being entered is the very first access recognizes, and that tells me that the date is noit going into the field correctly. Two things to check/try. First, make sure the field is properly formatted as a date type...second, try including the following for the OnOpen event of the form:

Me![TaskDate].DefaultValue = Date()

This will set the field to "something" when it opens, and thereby should eliminate the possible "ghost" date of 12/30/1899.

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
The code doesn't allow me to put the parentheses in date() in the code:Me![TaskDate].DefaultValue = Date() for the OnOpen event of the form.

So with the code: Me![TaskDate].DefaultValue = Date (with no parentheses after date) the very default value is now 12/30/1899.

I will be here at 7:30 CST tomorrow. I would appreciate any more ideas now if you have them. Also FYI, I'm running Access 97 and the Available references in the code are Visual Basic for Applications, MS Access 8.0 Object Library, MS Access DAO 2.5/3.5 Compatibility Libray (I tried 3.51 also).
 
gmillerinc

And have you tried using CTRL-' (apostrophe)
This will retrieve the value for the specific field from the previous record. A very cool short-cut.

Richard
 
Yeah that is cool. But this is a system that I'm implementing for users in a department here at work. I need the previous date to automatically pull up.
 
Put "#" signs around the value to make it 'see' it correctly as a date. Here's what worked for me:
Me![txtDate].DefaultValue = "#" & Me![txtDate].Value & "#"

---------------------------------------
The customer may not always be right, but the customer is ALWAYS the customer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top