ACC95: Using FindFirst Method to Find a GUID Generates an ErrorID: Q155194
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you use the FindFirst method of a recordset to find a globally unique
identifier (GUID), you may receive one of the following error messages:
Malformed GUID in expression
-or-
GUID not allowed in Find method criteria expression
A GUID is a 16-byte array. In table Datasheet view, a GUID appears as a string of hexadecimal numbers enclosed in braces. The value of an unbound combo box whose bound column is a GUID will be a string of hexadecimal numbers enclosed by braces. The FindFirst method will not be able to find a record with a GUID equal to that string.
Create an AfterUpdate event procedure that moves through the form's
recordsetclone to find the record with the GUID that matches the value in
the combo box. Set the bookmark of the form to the bookmark of the
recordsetclone.
The following example shows you how to find a record on a form using a
combo box whose bound column is a GUID:
Combo box: GUIDFind
---------------------
Name: GUIDFind
RowSource: Employees1
ColumnCount: 2
ColumnWidths: 0";1"
Private Sub GUIDFind_AfterUpdate()
Dim rs as Recordset
Dim findguid as String
findguid = "{guid " & Me!GUIDFind & "}"
Set rs = Me.RecordsetClone
rs.MoveFirst
Do Until rs.EOF
If rs!EmployeeID = findguid Then
Me.Bookmark = rs.Bookmark
Exit Sub
End If
rs.MoveNext
Loop
End Sub
Another way to represent a GUID is to convert it to a string using the
StringFromGUID() function.
For example, if you print the value of a text box bound to a GUID in the
Debug Window, you see a series of question marks because Microsoft Access
7.0 cannot display the 16-byte array. However, if you convert the value
with the StringFromGUID() function, you see a string of hex numbers
preceded by the word guid and enclosed by another set of curly braces. For
example:
debug.print StringFromGUID(Forms!formname!textboxname)
{guid {3B9B63A3-863D-11CF-8CAE-00AA00C0016B}}
GUID not allowed in Find method criteria expression
Malformed GUID in expression
For more information about globally unique identifiers, search for "GUIDs,"
using the Microsoft Access 7.0 Help Index.
For more information about the StringFromGUID function, see the section
called "Referring to a Replication ID Field in Code" in the Acreadme.txt
file, which is located in the Microsoft Access 7.0 program folder.
Keywords : kbusage FmsCmbo
Version : 7.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 23, 1999