Link to home
Start Free TrialLog in
Avatar of shambalad
shambaladFlag for United States of America

asked on

Converting DAO Field Property GUID

I am trying to write a procedure that lists the field properties and attributes for the tables in a database.
The procedure loops through all of the DAO Field Properties.
One of the properties is a GUID (at least that's what its name is). If I look at the value of this property in the local window, it is defined as 'variant/byte (0 to 15)'.
User generated imageI am trying to figure out how to convert this value to a standard GUID format
e.g.:      {361AA560-4FB1-11D3-AAE0-00104BA31425}
In the past, I have used a module (basGUIIDs) for handling GUIDs. The code is listed below. This module defines a public variable type named GUID:

Public Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(7) As Byte
End Type

All of the procedures in the basGUIDs module use this GUID type for input.
I tried to add some code to the procedure to convert the value to a GUID, but I'm running into a problem.  In my procedure, if the property name is 'GUID', I attempt to move the property value into a variable defined as type GUID:

Dim GID As GUID

If .Name = "GUID" Then
      GID = .Value

I am getting a compiler error on the 'GID = .Value' line:

Compiler Error
Only user-defined types defined in public object modules can be
coerced to or from a variant or passed to late bound functions.
User generated imageI don't really know what this error means and how I should handle it. I have a feeling this particular approach isn't going to work anyway.
My question is how can I convert this array into a 'standard' GUID? Or am I completely off base here?
For the purposes of this question, I have attached a copy of the database. I am working with Access 2010 (32 bit) on a Windows 7 Ultimate (64 bit) platform.
Thanks,
Todd
GIUD-Compile-Error.accdb
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shambalad

ASKER

Hex! That's the function I was looking for.
I have done little with bytes, binaries and hexadecimals in the past. This has been a learning experience for me.
Your function works like a charm.
Thank you for your help.
Todd