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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto fill forms

Status
Not open for further replies.

nicolea

Instructor
Joined
Jan 21, 2004
Messages
9
Location
US
I need to know how to make a form fields auto fill to the next record.
 
Check out the DefaultValue property of fields, in the tables definition window.

To change the default in fly on the code when operating on the table through a form, do something like:

CurrentFieldValue = Forms!frmYourForm!txtYourControl
Forms!frmYourForm!txtYourControl.DefaultValue = CurrentFieldValue

You might for example add the above code to the BeforeUpdate event of the control on the form.

HTH


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
What if the control is a date I want formatted mm/dd/yyyy.

Using this code:

CurrentFieldValue = Forms!frmYourForm!txtYourControl
Forms!frmYourForm!txtYourControl.DefaultValue = CurrentFieldValue

User puts in 1/1/2004

It defaults to 12:00:43 AM

If I format the control as Short Date it defaults to 12/30/1899. It doesn't matter what date I input the default shows as 12/30/1899?

If I format the control as General Date it defaults to 12:00:43.

If I do the following it still shows as 12/30/1899
CurrentFieldValue = Forms!frmYourForm!txtYourControl
Forms!frmYourForm!txtYourControl.DefaultValue = format(CurrentFieldValue,"mm/dd/yyyy")

Help!
 
try applying the CVDate (convert to date) function to the user supplied control's value; ie:

CurrentFieldValue = CVDate(Forms!frmYourForm!txtYourControl). Its currently converting the results of 1 divided by 1 divided by 2004 to a datetime; hense the funny results.




Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
...Steve is correct, but better yet, convert the form variable to a date datatype so you won't have to concern yourself with altering stuff back and forth all the time.


Jim

Don't be sexist - Broads hate that.
Another free Access forum:
More Access help stuff at
 
Quite right Jim .... I had assumed that the form's control was unbound, but looking at the greater context of the thread it is bound; hense the field type should be date.



Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top