jeudi 9 avril 2015

Auto populate Access 2010 Form with an entry from different field in last row

I'm making an access 2010 form that is going to be used as the front end to populate a flat table within the same database.

The Access form has "From" and "To" fields. When the user fills out the entry and clicks forward to a new row (Fresh form) - I'd like for the "From" field in the fresh form to auto populate with the last entry's "To" field.

So to clarify I'd like to know how to make a procedure so that when a user is filling out a form using it as the front end to populate a flat table - the "From" field in a new row will automatically populate with the "To" from the last row. These are From, To measurements thus From: 0.00 meter To:1.00 meter in the first row will become From: (Autopopulated with last "To" field) with the new "To" field blank for manual entry. I'm very new to VBA etc. so if you could specify what something is, "Table", "Field" vs. using examples where I may not know the equivalent in my particular case that would be much appreciated.


Thank you kindly


UPDATE:


Hi Mark! I'm so amazed that this community exists. I really appreciate you taking the time to assist me. I'm afraid in order for me to get this you will have to dumb it down a bit more. I've never taken any training on this at all.


What I tried is clicking the FROM text field in design view. I went to event and in the "after update" field I clicked the ... then selected Code Builder. In the code I entered:



Dim rst as DAO.Recordset
Dim sSql as String
Dim myValue as String
ssql = "select * from [HEADER]"
Set rst = currentdb.openrecordset(ssql)
with rst
.movelast
myValue = !TO
.addNew
.edit
!FROM = myValue
.update
end with
rst.close
set rst = nothing


It's not working yet. I know it's probably something I've neglected. I've never done anything like this before. I think I do need to use your last scenario as I don't want the From and To to be the same in the form, I will need for the From to come from the prior row's To. Any suggestions for what error I've made?


Aucun commentaire:

Enregistrer un commentaire