initialize form field from previous entry

  • Thread starter vince c via OfficeKB.com
  • Start date
V

vince c via OfficeKB.com

I'm using the menu's Data Form function called by a macro to enter new
records to a spreadsheet database used to track employee time to be billed on
client matters. For simplicity, assume the fields corresponding to the
columns in the database are: employee, file number, time, code and code
description. It is common that groups of related records are entered in
sequence where, for example, each new record in a group is has the same file
number and employee. Employee and code fields validate from respective lists.
Code decription field populates from a VLOOKUP function based on code field
entered. I'm calling the Data Form from the menu via a macro. Each new
entry, however, begins with a clear cell for each field. I'd like to have
the fields, at least employee and file number fields, for each new record to
be added initialize with the values entered for the immediately previous
record so that the information does not need to be re-entered for each new
record. Is there any way to do this using the Data Form? Will I need to
create a different data entry form in VB? Very much a newbie attempting this
but generally a quick study.

Thanks!
 
T

TylerDurden

As far as I can tell, You will need to create a text_box Enter privat
sub

I just put 1 small column of data in but the theory should hold tru
for your example. For each field you want to be pre populated you coul
reference the colomn in the last data you entered. I referenced A1 a
the only cell to look at, but in your case you're constantly enterin
in data into multiple columns so you'll have to code in something lik
this for each column of data, and subsequently each text box:

Private Sub TextBox1_Enter()
'locate the column of data you want to reference the last cell in
Range("A1").select
'Find the last cell (assuming no blank cells)
Selection.End(xlDown).Select
TextBox1.Value = Selection.Value
End Sub

Keep in mind you'll also need the requisite TextBox_1Change() to ente
your data into the next cell.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top