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

default input in text box from previous form

Status
Not open for further replies.

Dewey

Programmer
Jan 25, 2000
21
US
I have ACCESS 2000 running a form, that the first text box calls for the date, which is formatted and masked. However at each session I may enter 200 forms in this db. I would like for the next form to remember the date from the previous form. This would save numerous keystrokes daily. maybe defining a function, would work, but I really need to keep it simple. any help is appreciated..... <p>Dewey Davis<br><a href=mailto:ddavis@dfn.com>ddavis@dfn.com</a><br><a href= > </a><br>
 
Dewey:<br>
In the form module, Declarations section:<br>
Dim locDatePrev as Date<br>
<br>
In the Date Field's (txtSomDate) After Update:<br>
locDatePrev = me!txtSomeDate<br>
<br>
In the Form's Before Insert:<br>
If IsNull(Me!txtSomDate) Then Me!txtSomeDate = locDatePrev<br>
<br>
--Jim
 
---Just re-read your question-do you mean 200 Forms, or 200 records?<br>
If it's 200 forms, then we have some other issues to deal with, not the least of which is this textbox issue :)<br>
--Jim
 
You can grab the previous date several ways<br>
NO code way:<br>
Press Ctrl-&quot;; (the Control Key and the Quote key)<br>
this will bring over the previous value from the record above.<br>
<br>
Or if you make a &quot;Create New Record&quot; Button then you could Click it Which would add a new record and grab the previous date and set focus to a particular textbox to start keynig in data. This is the way I prefer.<br>
--------------------------------------<br>
Private Sub Command2_Click()<br>
On Error GoTo Err_Command2_Click<br>
Dim HoldDate As Date<br>
HoldDate = Me!date<br>
DoCmd.GoToRecord , , acNewRec<br>
Me!date = HoldDate<br>
Me!MyTextBox.SetFocus<br>
<br>
Exit_Command2_Click:<br>
Exit Sub<br>
<br>
Err_Command2_Click:<br>
MsgBox Err.Description<br>
Resume Exit_Command2_Click<br>
<br>
End Sub<br>
----------------------<br>
No keep in mind when you first open the form you need to position yourself on the last record you entered so it can grab the correct date.<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
It is for 200+ forms, not records... <p>Dewey Davis<br><a href=mailto:ddavis@dfn.com>ddavis@dfn.com</a><br><a href= > </a><br>
 
Dewey,<br>
Could you explain what you mean by &quot;at each session I may enter 200 forms in this db&quot;? I'm a little confused as to what you are doing. You open a new, separate form 200 times and enter data? Then you want each new form to know what the name of whatever the last form opened was, and a date value of a textbox on whatever that last form opened was? <br>
<br>
This will require a bit more work...including taking my previous example and instead of dimming locDatePrev in the Form scope Module, do it as <br>
Global glbDatePrev as date In a Module (not a Form Module)--giving it global scope.<br>
Then, it's fairly easy to write code that opens the 200 forms in design view and pastes this code in the textbox, assuming you named it the same or named it in a way that your code can iterate it. <br>
<br>
But I'm still curious about these 200 forms and their use...<br>
--Jim Horton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top