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

default for text box=previous entry 1

Status
Not open for further replies.

munger

Programmer
Feb 28, 2001
23
0
0
IL
It must be possible to program a text box in a new record to show wht the user entered in the previous record.

Anybody want to reveal me the code?

M.
 
1) users can always type CTRL ' (control key and apostrope at the same time) in a field and Access will copy the previous value to that field

if you still need to automate:

2) if you have multiple users entering data, then you won't be able to tell what a certain user entered unless you also keep track of a user id in each record. is this the case? if so you will need more code that what is below.

3) if there is only one user, or you don't care what user entered in the last value and you just want to copy the data from the previous record, put in the form's BEFORE INSERT put an [Event Procedure] and copy this. You will have to change the name of the Table, ID, Form, TextBox and Value1 to your own values.

Private Sub Form_BeforeInsert(Cancel As Integer)
'Determine ID in the underlying table of the last record entered

Dim CurrentID
CurrentID = DMax("ID", "Table1")

'Lookup the value in the table with the ID you just determined and set
'the text box of the current record to it

Me.TextBox = DLookup("Value1", "Table1", "[ID] = " & CurrentID)

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top