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

Fill a record with data - Access 2007

Status
Not open for further replies.

punky001

Programmer
Oct 1, 2007
34
US
Can someone please give me some suggestions for filling a record with data from a previous record?
EX:
Field1: 1234
Field2: Test 2
Field3: Test 2 aa
Field4: Test 2 bb

This would be my first record and any other new records would have fields 1 and 2 automatically filled with data from the first record.

Any ideas?
 
The fields I want duplicated from record to record may change - so I don't think I can use a default value - can I?

For Example: the user may enter 20 records with fields 1 and 2 the same. The next day the first time they enter a record - fields 1 and 2 changes for the first record but may be the same for a number of records they enter.
 


HOW is the user entering data? Using a FORM?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You might try

1) Create a Global Field for each form field you want to repeat
2) Create Functions that return the Global field Value and use the function in the Default value of the form field
3) In the after update event of each field, set the corresponding global Field to the new value just entered.

That should handle filling in recently entered values as 'Default Values' for new records.

Hope This Helps,
Hap...

Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
How are ya punky001 . . .

With the following code, double clicking the [blue]record selector[/blue] of any previously saved record sets the defaults. Here's how to install:
[ol][li]Put a question mark [blue]?[/blue] ([red]no quotations please[/red]) in the [blue]Tag[/blue] property of the textboxes of interest.[/li]
[li]In the forms [blue]On Dbl Click[/blue] event, copy/paste the following:
Code:
[blue]   Dim ctl As Control, DQ As String
   
   DQ = """"
   
   If Not Me.NewRecord Then
      For Each ctl In Me.Controls
         If ctl.Tag = "?" Then
            ctl.DefaultValue = DQ & ctl & DQ
         End If
      Next
   End If[/blue]
[/li]
[li]Thats it! ... perform your testing.[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top