[AccessD] Clone an object

Edward S Zuris edzedz at comcast.net
Wed May 21 12:09:30 CDT 2008


 Hi John

 This might be helpful or suggest a place to look.

 Here is one example of clone using a record set
 to make sure a sub form view returns to the item
 we are working on.

 Sincerely,
 Edz. . . .

 ========================================================

 Option Compare Database
 Option Explicit

    Public gzForm                       As Form
    Public grsSeek                      As DAO.Recordset
    Public rsSetNav                     As DAO.Recordset
    Public grsFrmBook                   As DAO.Recordset
    Public grsSetNav                    As Long
    Public gzFile                       As String
    Public gzPath                       As String

    Public gEditCount                   As Long
    Public gEditRecNum                  As Long
    Public hEditRecNum                  As Long

    Public gEditLoop                    As Long

    Public gEditCountMF                 As Long
    Public gEditRecNumMF                As Long
    Public gBookmark                    As Variant
    Public gSeekErr                     As Long
    Public gsYear                       As String
    Public gsMonth                      As String
    Public gsWeek                       As String
    Public gsType                       As String
    Public gsTaskGroup                  As String
    Public gsDay                        As String


Public Function zzzNextField(zDo As Long) As Long

    Dim sSQL                As String
    
    Dim sTmp0               As String
    Dim sTmp1               As String

    Dim lTmp0               As Long
    Dim lTmp1               As Long

    Dim lEditLoop           As Long

    sTmp0 = ""
    sTmp1 = ""

    DoEvents

    On Error Resume Next
       grsFrmBook.Close
    On Error GoTo 0

    ' *****************************************************
    '  @NextField
    '  How Many Edit sub-records do we have now ?
    '
    Set grsFrmBook = [Forms]![frm101App]![SubApp2].Form.RecordsetClone

    grsFrmBook.MoveLast
           gEditCount = grsFrmBook.RecordCount
    grsFrmBook.MoveFirst
  
    If hEditRecNum + 1 > gEditCount Then
       hEditRecNum = 1
    Else
       hEditRecNum = hEditRecNum + 1
    End If

    lEditLoop = 1

    grsFrmBook.MoveFirst

    Do While lEditLoop < hEditRecNum
        grsFrmBook.MoveNext
        lEditLoop = lEditLoop + 1
    Loop

    [Forms]![frm101App]![SubApp2].Form.BookMark = grsFrmBook.BookMark
 
 
    On Error Resume Next
       grsFrmBook.Close
    On Error GoTo 0

     DoEvents

 End Function

 ==================================================


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of jwcolby
Sent: Wednesday, May 21, 2008 8:56 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Clone an object


Is there a way in VBA to "Clone" an object, in particular a field of a 
recordset.  I want to open a DOA recordset, get a COPY of the entire 
field object for each field in rst.fields.

I do not want a copy of the POINTER to the existing field.

IOW I can create a field object at will by dimming and setting as new. 
Now I need to take a field in a recordset and copy all of the properties 
of that field into the same properties in the field I just created.

I have no idea how to do that.

Anybody?

-- 
John W. Colby
www.ColbyConsulting.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list