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

Use previous record in a table as the default for a form

Status
Not open for further replies.

gxd135

MIS
Jun 18, 2001
41
US
I have a form with four fields. The form is linked to a table, and I want the default value in the form to be the LAST value in the table. I know that I could write a query to run everytime a new record is added to give the last value, but I wanted to find some other suggestions. Thank you in advance.
 
There are keyboard strokes that copy values from the previous record. The keystroke is [Control][']. To automate this for a field on your form, you must check to see if the record is a new record and the value is the field is null. If so, use the sendkeys function to send [Control][']. Do this in the GotFocus event for each field.

example:

Private Sub Dept_Division_GotFocus()
;If this is a new record, default to the value
;of Dept_Division of previous record.

Dim NewRec As Integer
Dim Frm As Form
Set Frm=Screen.ActiveForm ;Set Frm to the active form.

;Is the current record a new record?

NewRec=Frm.NewRecord
If NewRec=True Then
If IsNull([Dept_Division]) Then
SendKeys("^'")
End If
End If

The above code will place the value of the last record into the field Dept_Division as soon as Dept_Division gets focus.

Hope this works for you.

Have a very happy new year.

o<|:eek:)
 
While I am far from an expert in access I can tell you that from my experience it seems best to have each users front end on their own hard drive - I know that it makes it more of a pain to update their forms but it seems to help speed up the database.

There have been other posts on this website that address these issues.

I have also experienced problems when I was in the same front end as one of the users of my database - At one time, I had all of the users front-ends on a network drive -

I did find it more helpful when each users front end was seperate for a few reasons - first, I could go into windows explorer and see who was in the database when I told them to get. Second, it makes updating easier.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top