Application.GUIDFromString method (Access)
The GUIDFromString function converts a string to a GUID, which is an array of type Byte.
Syntax
expression.GUIDFromString (String)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
String | Required | Variant | A string expression that evaluates to a GUID in string form. |
Return value
Variant
Remarks
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.
Example
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기