Autofilling fields from previous record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I make the default value in my fields be the same as the previous record????

Thank you
 
DJ said:
How do I make the default value in my fields be the same as the previous record?????


Depends on what you mean by "previous". If you mean the new
record that was just created in the current session of the
form, then you can use the following in each data control's
AfterUpdate event:

Me.controlname.DefaultValue = """" & Me.controlname & """"
 
Thank you Marshall. What I want to do is
1. Create a record with a customer nam
2. Then the next record will automatically fill in the name of the previous custome

This form is for rapid data entry, so it would be helpful if I had information to fill in for one customer but 10 different items, if the customer name or number was automatically filled in when I create a new record. If your answer is to this, can you advise further as where I put it?? Again, thank you.
 
DJ said:
Thank you Marshall. What I want to do is:
1. Create a record with a customer name
2. Then the next record will automatically fill in the name of the previous customer

This form is for rapid data entry, so it would be helpful if I had information to fill in for one customer but 10 different items, if the customer name or number was automatically filled in when I create a new record. If your answer is to this, can you advise further as where I put it?? Again, thank you.


Yes that's the kind of situation where this will do what you
want. the line of code would go in the customer name text
box's AfterUpdate event procedure.
 
Marshall it's me again!!!

Sorry, I feel really really stupid about this.

what does "me" stand for. In the example you gave me for
duplicating the fields, do I put my field name as
the "controlname" I'm so sorry to keep asking you how to
do this.

Thanks DJ
 
DJ said:
what does "me" stand for. In the example you gave me for
duplicating the fields, do I put my field name as
the "controlname"

Time out while we get the nomenclature straight. Controls
are the thingies you put on a form/report (labels, text
box,buttons, etc). Fields are the columns in a table or
query. When you want a form/report to interact with a
table/query, you use a control that is bound to a field.

Me refers to the form where the code is running. It's a
generic object that makes your code shorter and independent
of where it was copied from. It's not strictly required
unless you have a variable with the same name as a control
on the form or a field in the form's record source
table/query. In a form, you can refer to either a control
or a field with the syntax Me.controlname or Me.fieldname.
Alternate syntax that will do the same thing is to replace
the dot with a bang (!) or to use Me("controlname") or
Me("fieldname"). The different syntaxes provide some
different features, so they're not strictly interchangable
in all situations.

To answer your second question, I meant for you to replace
"controlname" with the name of the text box that is bound to
the field you want to update (as per the above explanation,
using the field name would probably work too). The control
name may or may not be the same as the name of the field (I
usually make sure they are different so I know which one I'm
using).
 
Thank you Marshall. What I want to do is:
1. Create a record with a customer name
2. Then the next record will automatically fill in the name of the previous customer

This form is for rapid data entry, so it would be helpful if I had information to fill in for one customer but 10 different items, if the customer name or number was automatically filled in when I create a new record. If your answer is to this, can you advise further as where I put it?? Again, thank you.

Well... I'd suggest storing the customer name ONCE, and once only, and
only in the Customer table. If you're storing the customer name in
every record of an item the customer orders, you're not taking
advantage of the power of Access as a relational database!

Typically in an orders application (like the Northwind sample
database), you will have several tables: Customers, related
one-to-many to Orders, related one-to-many to OrderDetails, related
many-to-one to Products. Forms and Subforms make it easy to create an
order with multiple items; the items are linked to the customer table,
but you don't store the customer information *in* the items table!
 
I have the following scenario, possibly there is a better
way to do it, but I don't know for sure:

We have several thousand customers, each customer has
equipment at their location which we service. The
equipment has to be listed in the order in which it is
serviced, to save time, plus have the necessary parts,
etc., on board the trucks to service customer equipment.
At the beginning of the month we print work orders for
the entire month. We need to match up each work order in
a SQL dbase with the equipment sheets I am putting in
Access. The report is being pulled together by me in
Crystal Reports. The reason the customer number has to
be repeated is because the only way to put the equipment
in the order we need to, is to number it sequentially.
The customer number is being used as an 'anchor' field to
keep the equipment in the proper order.

Probably sounds like more work then necessary, but the
manager insists it has to be this way - I have created an
input form to help put the equipment and info about the
equipment into the data table using the features in
Access to make for rapid data entry, however, if a
customer has 100 pieces of equipment to be serviced, it
just doesn't make sense to retype the customer number 100
times. The customer number field is the main sort field,
then the order the equipment is serviced is the second
sort field.

As stupid as I might sound, I still can't figure out how
to make this statement work in order to do what I need to
do. Any help would be appreciated.

Thanks
DJ
-----Original Message-----
helpful if I had information to fill in for one customer
but 10 different items, if the customer name or number
was automatically filled in when I create a new record.
If your answer is to this, can you advise further as
where I put it?? Again, thank you.
 
If this is *just* data entry, and nothng else.. there's a
sneaky keyboard shortcut to "retrieve" the previous
records' data and place it into the current record. Click
on the text box or whatnot and do Ctrl + Alt' (or
something similar to that). This will repeat the data
manually, not programmically which would be loads easier,
but it should work for a temporary fix... As for the
programming, it's a pain the rear as I've been slogging
through the coding for the database I'm working on for
like 3 months now...

You could do what I do which is I have a drop down menu
(combo box) on my product form to "autofill" the
description. The dropdown box is coded: "Select distinct
[product].productname, [product].description from
products;" (you can get similar code from Help) anyway,
the column# is set to 2, but the widths are 3"; 0"; (to
hide the description column). Then in the Afterupdate
field, code: "description = Me!ProductName.Column{1}".
This will auto-fill the description in the proper box.
This should work, good luck!
sam
 
If this is *just* data entry, and nothng else.. there's a
sneaky keyboard shortcut to "retrieve" the previous
records' data and place it into the current record. Click
on the text box or whatnot and do Ctrl + Alt' (or
something similar to that). This will repeat the data
manually, not programmically which would be loads easier,
but it should work for a temporary fix... As for the
programming, it's a pain the rear as I've been slogging
through the coding for the database I'm working on for
like 3 months now...

You could do what I do which is I have a drop down menu
(combo box) on my product form to "autofill" the
description. The dropdown box is coded: "Select distinct
[product].productname, [product].description from
products;" (you can get similar code from Help) anyway,
the column# is set to 2, but the widths are 3"; 0"; (to
hide the description column). Then in the Afterupdate
field, code: "description = Me!ProductName.Column{1}".
This will auto-fill the description in the proper box.
This should work, good luck!
sam
 
Thank you Sam -- it's CTRL ' in a form. What a trip this
has been for me LOL. I have most of what I need to
create forms and dbases, just some of this stuff is a bit
tricky.

Thanks again.

DJ
-----Original Message-----
If this is *just* data entry, and nothng else.. there's a
sneaky keyboard shortcut to "retrieve" the previous
records' data and place it into the current record. Click
on the text box or whatnot and do Ctrl + Alt' (or
something similar to that). This will repeat the data
manually, not programmically which would be loads easier,
but it should work for a temporary fix... As for the
programming, it's a pain the rear as I've been slogging
through the coding for the database I'm working on for
like 3 months now...

You could do what I do which is I have a drop down menu
(combo box) on my product form to "autofill" the
description. The dropdown box is coded: "Select distinct
[product].productname, [product].description from
products;" (you can get similar code from Help) anyway,
the column# is set to 2, but the widths are 3"; 0"; (to
hide the description column). Then in the Afterupdate
field, code: "description = Me!ProductName.Column{1}".
This will auto-fill the description in the proper box.
This should work, good luck!
sam
-----Original Message-----
I have the following scenario, possibly there is a better
way to do it, but I don't know for sure:

We have several thousand customers, each customer has
equipment at their location which we service. The
equipment has to be listed in the order in which it is
serviced, to save time, plus have the necessary parts,
etc., on board the trucks to service customer equipment.
At the beginning of the month we print work orders for
the entire month. We need to match up each work order in
a SQL dbase with the equipment sheets I am putting in
Access. The report is being pulled together by me in
Crystal Reports. The reason the customer number has to
be repeated is because the only way to put the equipment
in the order we need to, is to number it sequentially.
The customer number is being used as an 'anchor' field to
keep the equipment in the proper order.

Probably sounds like more work then necessary, but the
manager insists it has to be this way - I have created an
input form to help put the equipment and info about the
equipment into the data table using the features in
Access to make for rapid data entry, however, if a
customer has 100 pieces of equipment to be serviced, it
just doesn't make sense to retype the customer number 100
times. The customer number field is the main sort field,
then the order the equipment is serviced is the second
sort field.

As stupid as I might sound, I still can't figure out how
to make this statement work in order to do what I need to
do. Any help would be appreciated.

Thanks
DJ

the name of the previous customer
helpful if I had information to fill in for one customer
but 10 different items, if the customer name or number
was automatically filled in when I create a new record.
If your answer is to this, can you advise further as
where I put it?? Again, thank you. and
once only, and not
taking easy
to create an
.
.
 
Back
Top