StringFromGUID Function

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

Syntax

StringFromGUID ( guid )

The required guid argument is an array of Byte data used to uniquely identify an application, component, or item of data to the operating system.


Remarks

The Microsoft Access database engine stores GUIDs as arrays of type Byte. However, Microsoft Office Access 2007 can't return Byte data from a control on a form or report. In order 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 back to a GUID, use the GUIDFromString function.

For example, you may need to refer to a field that contains a GUID when using database replication. To return the value of a control on a form bound to a field that contains a GUID, use the StringFromGUID function to convert the GUID to a string.

Example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

The following example returns the value of the s_GUID control on an Employees form in string form and assigns it to a string variable. The s_GUID control is bound to the s_GUID field, one of the system fields added to each replicated table in a replicated database.

Public Sub StringValueOfGUID()
Dim ctl As Control
Dim strGUID As String
' Get the GUID.
Set ctl = Forms!Employees!s_GUID
Debug.Print TypeName(ctl.Value)
' Convert the GUID to a string.
strGUID = StringFromGUID(ctl.Value)
Debug.Print TypeName(strGUID)
End Sub
Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×