Add/Edit fields

  • Thread starter Thread starter Gunnywolf
  • Start date Start date
G

Gunnywolf

I am trying to have data entered into an add/edit field carried over to the
next add screen until the data is changed. Example - If I put "Name" in the
first screen when I enter into a new screen the "Name" still shows in the
field and stays that way for every record until it is physically changed -
but it also stays in edit screens as well.
 
You can use default values when the form is at a new record.
Here is a couple of ways to do it.

In a form to enter data, use the field's OnGotFocus event.
Copy, paste, and edit the following code:


'Fetching default value from previous record
Dim rs As Object
Set rs = Me.RecordsetClone

' Don't do anything if no previous record exist or not new Record
If rs.EOF Or Not Me.NewRecord Then
Else
With rs
..MoveLast
Me![YourFieldNameHere] = .Fields("YourFieldNameHere")
End With
Set rs = Nothing
End If

When you tab over to the field, it will default to the previous record's
value.



Private Sub controlname_AfterUpdate()
Me.controlname.DefaultValue = Chr(34) & Me.controlname & Chr(34)
End Sub

Thus if the user enters XYZ it will set the DefaultValue property to

"XYZ"

which will be used for the next entry.

If you want a subform to inherit a value from the mainform (and don't want
it
editable) you can make that field part of the Master/Child Field pair.


If you try the same for editing data, you will find that setting the default
value will overwrite any legitimate values in that field. That might be a
disaster or not depending on what you are trying to do.

Jeanette Cunningham
 
Sounds like a table design issue rather than a form issue. You probably
need to split the table into two tables. One table will be the "parent" and
will contain the data that occurs one time and the other table will be the
"child" and will contain the data that changes with each record. You would
then use a form for the "parent" data and a subform for the "child" data.
 
Back
Top