Autofill/Copy data from previous record by clicking a button on a form

  • Thread starter Thread starter Another_Access_Dummy
  • Start date Start date
A

Another_Access_Dummy

Hello all,

I have been searching these newsgroups for about 3 days and I have come
close, but I haven't found the answer to what I need.

I have 1 form that is bound to one table with caller information in a
call center environment. Many times we get one call, but the user has
2 different issues that we need to log.

Therefore, I would like my users to be able to click a button called
"Start New Record with Same Caller Info" that would go to a new record
in the form and populate the caller name, phone number, etc along with
it. I realize my users can use CTRL ' and that is what I have them
doing right now, but soon we will be required to handle more calls
during the day so they will need quicker tools.

I have been unsuccessful with the AutoFill function that Microsoft help
provides as well as other tidbits of code I have found on these posts.


Can anyone help me get this taken care of? I'm sure I'll slap myself in
the forehead when someone tells me. Thank you!
 
Set the bookmark of the form's Recordset to the current record.
You can then move to the new record, and copy the fields.

This kind of thing:

Dim rs As DAO.Recordset

'Save any edits
If Me.Dirty Then
Me.Dirty = False
End If

'Make sure there is a record to copy from.
If Me.NewRecord Then
Beep
Else
'Point the clone set to the current record.
set rs = Me.RecordsetClone
rs.Bookmark = Me.Bookmark
'Move the form to the new record.
RunCommand acCmdRecordsGotoNew
'Copy the fields.
Me.Caller = rs!Caller
Me.CallDateTime = rs!CallDateTime
Me.Phone = rs!Phone
'etc

End If
Set rs = Nothing
 
I am thinking that a better approach would be to use a keyed approach. I mean
simply (2) tables that are keyed off of some key.

Example

Table 1
CustomerID as autonumber
name as string
address as string

table 2
InputsID as autonumber
CustomerID as number(long)
Situation as string

The two tables have a 1 to many relationship (table 1 to table 2).

Then on the main form add a sub form with the parent a child CustomerID from
both forms.

At the top of the main form you can display the common data and not have to
repeat it.

In the sub-form you can enter the new information and not worry about
entering the common data again as it was entered once already.
 
Thank you Mr. Browne....do I put this code in the OnClick event of the
button?
 
Thank you, Dave_C - I'm afraid I'm a little confused by this. I'm
willing to try anything, but I already have developed a form that is in
practice right now and that my users are comfortable with.
 
Set the button's On Click property to:
[Event Procedure]

Then click the Build button (...) beside this property.
Access opens the code window.
Set up the code in there.
 

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

Back
Top