Application.GUIDFromString (Access)

The GUIDFromString function converts a string to a GUID, which is an array of type Byte.

The Microsoft Access database engine stores GUIDs as arrays of type Byte. However, Access can't return Byte data from a control on a form or report. To return the value of a GUID from a control, you must convert it to a string. To convert a GUID to a string, use the StringFromGUID function. To convert a string to a GUID, use the GUIDFromString function.

GUIDFromString (String)

String: A string expression that evaluates to a GUID in string form.


Sub CheckGUIDType() 
 
 Dim dbsConn As ADODB.Connection 
 Dim rstEmployees As ADODB.Recordset 
 
 ' Make a connection to the current database. 
 Set dbsConn = Application.CurrentProject.Connection 
 Set rstEmployees = New ADODB.Recordset 
 rstEmployees.Open "Employees", dbsConn, , , adCmdTable 
 
 ' Print the GUID to the immediate window. 
 Debug.Print rst!s_GUID 
 Debug.Print TypeName(rst!s_GUID) 
 Debug.Print TypeName(GuidFromString(rst!s_GUID)) 
 
 Set rstEmployees = Nothing 
 Set dbsConn = Nothing 
 
End Sub