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!

REPEATING PREVIOUS RECORD VALUE IN A DATA ENTRY FORM

Status
Not open for further replies.

slapupp

Technical User
Aug 30, 2001
14
0
0
US
I have a simple data entry for that I am using to enter records in a table. Many of the fields are repetitive from the previous record. Is there a way to have the default value for the new record default in the form to the value of the previous record.

Thank You

Mike
 
Hi Mike,
Have the EXACT issue to solve. Users want the text in the prior remark text box to redisplay in the next record to save data entry for them.
One possible solution (that is not working yet) is to copy off the text from the prior record into a hidden text box which is then moved into the new record. Am testing for NewRecord in Form_Current() but don't like the way it's working.
Any suggestions greatly appreciated.

Steve.
 
Hi!

One workaround is to set the default value of the control to its own Tag property and in the Before Update event of the control put the code:

txtBox.Tag = txtBox.Value

This will bring whatever was in the text box to the empty record. Of course this will only work once the user starts entering records.

hth
Jeff Bridgham
 
OK, here's the recordsetclone way of doing it with DAO.

Dim rst As Recordset
Dim rstClone As Recordset
Set rst = me.RecordsetClone
rst.Bookmark = me.Bookmark
Set rstClone = rst.Clone
rstClone.Bookmark = rst.Bookmark
rstClone.MovePrevious
me.txtYourField = rstClone(strFieldName)
me.txtYourField1 = rstClone(strFieldName1)
me.txtYourField2 = rstClone(strFieldName2)
'etc
rstClone.Close
Set rstClone = Nothing
Set rst = Nothing
End Function
Tyrone Lumley
augerinn@gte.net
 
Hi Mike,
Here is the solution that works for me, although
Jeff's txtBox.Tag = txtBox.Value seems even better.

Option Compare Database
Dim txt As String

Private Sub Form_AfterUpdate()
REMARK.SetFocus
txt = REMARK.Text
End Sub

Private Sub Form_Current()

intnewrec = Forms!frmHD8130EX.NewRecord

If intnewrec = True Then
REMARK.SetFocus
REMARK.Text = txt
End If

End Sub


Steve.
 
Another way:

In the AfterUpdate event of the form, set the DefaultValue on the individual text boxes that you want defaulted to the value from the current record:

MyTextBox.DefaultValue = MyTextBox

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top