Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

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

Syntax

GUIDFromString ( stringexpression )

The required stringexpression argument is a string expression which evaluates to a GUID in string form.

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 to a GUID, use the GUIDFromString function.

Query example

Expression

Results

SELECT userID,GUIDfromString(userGUID) as GUIDCode FROM GUID_Table;

Displays the "userID", Converts the StringExpression(userGUID) into GUID (array of bytes) and displays in the column GUIDCode. This example only works for a string expression that can evaluate to a GUID.

VBA 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 uses the GUIDFromString function to convert a string to a GUID. The string is a GUID stored in string form in a replicated Employees table. The field, s_GUID, is a hidden field added to every replicated table in a replicated database.

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

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×