Copy Entire Record and Subform Records

gmatriix

Registered User.
Local time
Today, 16:36
Joined
Mar 19, 2007
Messages
365
Hello All,

Just trying to find out if there is an easier way of doing this. I know you can do something like this:
example
Code:
        Dim dbs As Database, Rst As Recordset
        Dim F As Form
        Dim scompany As String
        Dim saddress As String
        Dim scity As String
        Dim sstate As String
        Dim szip As String
        Dim sattention As String
        Dim sinquiryno As String

Set dbs = CurrentDb
Set Rst = Me.RecordsetClone

       With Rst
           .AddNew
              !company = scompany
              !Address = saddress
              !city = scity
              !State = sstate
              !Zip = szip
              !Attention = sattention
              !InquiryNo = sinquiryno
            .Update 

ect......

Do I have to list everything in the record or is there some sort of blanket code that will capture everything.....Just wondering..

Any Ideas?
 
Considering your 1-M requirement, then either that or a in memory Collection storage concept would be the first two options which come to my mind.
 
Depends on your naming convention. You can loop through the names of all the fields of a record set. If those names can be used to contruct the names of the other recordset or form controls (wherever the sourcedata is) , then yes, you do not need to list each and one explicitly. Conversely, you can access a specific field of a record set by

Dim a as string
a = "MySpecificField"
myvalue= rst(a)
 
Thanks spikepl,

Basically what I'm trying to do is copy the record that it is currently on and copy it to a new record. This saves the user time in generating similar data for a new record.

Any thoughts?
 

Users who are viewing this thread

Back
Top Bottom