Dump of current record data.

lawsonium

Registered User.
Local time
Today, 22:56
Joined
Jul 6, 2006
Messages
40
Hi,

I have failed to get the clipboard manipulating VBA working so can anyone tell me of another way that I can write the current record to a variable.

i.e. I am viewing a record on a form (not all fields are shown) I want to write the entire record (all fields) to a variable using VBA.

How can I do this?

Thanks,

Matt.
 
use a UDT - user defined type.
this is very much like a record structure. I use one to emulate the clipboard so I can 'copy' and 'paste' records.
 
ok, that sounds interesting, unfortunately I have never heard of it. Can yuo enlarge on it's usage or point me somewhere that covers it.

Thanks,

Matt.
 
this is from access help


Type Statement Example
This example uses the Type statement to define a user-defined data type. The Type statement is used at the module level only. If it appears in a class module, a Type statement must be preceded by the keyword Private.

Type EmployeeRecord ' Create user-defined type.
ID As Integer ' Define elements of data type.
Name As String * 20
Address As String * 30
Phone As Long
HireDate As Date
End Type
Sub CreateRecord()
Dim MyRecord As EmployeeRecord ' Declare variable.

' Assignment to EmployeeRecord variable must occur in a procedure.
MyRecord.ID = 12003 ' Assign a value to an element.
End Sub

I just checked my db and I use a class instead of a UDT, so it can be done using two different methods.

using a UDT means that the data is held on the local stack whilst a class being an object is located on the heap and so requires more overhead.
 
Hi, thanks for your reply.

The problem with this is that I won't automatically know what the fields are. I would like to take a dump of all the data in the current record without prior knowledge of the fields used.

Thanks,

Matt.
 
use an array and redimension it 'on the fly' to acomodate all the fields
 
reference the fields in the recordset like below

myRec.fields(0)
myRec.fields(1)
...
...
 

Users who are viewing this thread

Back
Top Bottom