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.

GUIDFromString 函數會將 字串 轉換為 GUID,也就是位元組類型的 陣列 。

語法

GUIDFromString ( stringexpression )

必要 stringexpression 自變數 是一個字串表達式,會評估為字串形式的 GUID。

註解

Microsoft Access 資料庫引擎會將 GUID 儲存 為位元組類型陣列。 不過, Microsoft Office Access 2007 無法從 表單 或 報表上的 控制項 傳回 元組數據。 若要從控件傳回 GUID 的值,您必須將其轉換為字串。 若要將 GUID 轉換成字串,請使用 StringFromGUID 函數。 若要將字串轉換成 GUID,請使用 GUIDFromString 函數。

查詢範例

Expression

結果​​

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

顯示 「userID」,將 StringExpression (userGUID) 轉換為 GUID (位元組) 數位列,並顯示在 GUIDCode 欄中。 此範例僅適用於可評估為 GUID 的字串表示式。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

下列範例使用 GUIDFromString 函數將字串轉換為 GUID。 字串是儲存在複製 [員工] 資料表之字串窗體中的 GUID。 s_GUID這個欄位是一個隱藏的欄位,新增到複本資料庫中的每一個複本數據表中。

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?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
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!

×