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

Default Value to bring in data from table

Status
Not open for further replies.

Solutus

Technical User
Jun 28, 2002
20
0
0
US
I have a simple form with a Date field. I want the Date field to have a default value on a new record that shows the last date that was entered. For example, the last date that was entered in the form was 2/10/04. Then on 3/1/04 I create a new record and want the date field to automatically plug in 2/10/04 (basically to show me the last time I entered info).

Right now I have the default to "Today" but would appreciate help to get it to show the last date entered.

TIA,

Debbie
 
Add a cmd button to your form. Under the cmd_click add this code


DIM sav as variant
sav = me.date1
DoCmd.GoToRecord ,,acNew
me.date2 = sav

exit sub

Use your name fields though.

rollie@bwsys.net
 
Here is what I had:

Private Sub cmdNewbutton_Click()
On Error GoTo Err_cmdNewbutton_Click

DoCmd.GoToRecord , , acNewRec
Forms!frmPatient!Date.SetFocus

Exit_cmdNewbutton_Click:
Exit Sub

Err_cmdNewbutton_Click:
MsgBox Err.Description
Resume Exit_cmdNewbutton_Click

End Sub

So, if I add your code, what are date1 and date2? I only have one field named Date.
 
The first is the date from the present record (it requires saving)and the second is the date from the new record (it is made the value of the first QED).

R
 
That works, but you have to make sure you are in the last record, and that they are sorted by date....but that does the job.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top