ACC95: Using FindFirst Method to Find a GUID Generates an ErrorLast reviewed: May 30, 1997Article ID: Q155194 |
The information in this article applies to:
SYMPTOMSModerate: 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 expressionIf you use the Combo Box Wizard on a form to create a combo box that finds a record based on a replication ID value, you may also receive this error. This is because the wizard generates Visual Basic for Applications code that uses the FindFirst method.
CAUSEA 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.
RESOLUTIONCreate 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:
MORE INFORMATIONAnother 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)displays something like this:
{guid {3B9B63A3-863D-11CF-8CAE-00AA00C0016B}}The FindFirst method also does not work with strings like this. You cannot use the StringFromGUID() function with an unbound combo box value because the value is already a string expression. If you concatenate "{guid " to the beginning of the combo box value and you concatenate "}" to the end of the value, then you receive the following error message when you use the FindFirst method:
GUID not allowed in Find method criteria expressionYou must use an AfterUpdate event procedure as described earlier.
Steps to Reproduce Behavior
REFERENCESFor 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 : FmsCmbo kbusage
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |