Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / February 2008

Tip: Looking for answers? Try searching our database.

Add/Edit fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gunnywolf - 30 Jan 2008 15:37 GMT
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.
Jeanette Cunningham - 30 Jan 2008 23:09 GMT
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

>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.
Pat Hartman - 01 Feb 2008 15:52 GMT
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.

>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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.