Private Function LongExplanation()
'GUID's (UniqueIdentifier) stored in SQL Server are stored in binary format and when
'passed to MSAccess (ADP project) they are naturally converted to a Byte(16) Array
'if you put a Watch on the field value Me![GUID] you can see the array.
'This is why there are the two functions StringFromGUID() and GUIDFromString() in VBA,
'the former (StringFromGUID) is used to help read the Guid from the field,
'the latter (GUIDFromString) is used to help write a string (properly formatted)
'to the field.
'use the StringFromGUID function to read the GUID and convert/pass to a string
Dim MyGUID As String
MyGUID = StringFromGUID(Me![Guid])
'the above will actually return the string with a little junk in it,
'which is probably why some people have problems with it.
'EXAMPLE: MyGUID = "{guid {E6919771-152B-463D-AC48-FFA22AB088FC}}"
'I've found that to use in an ADP project you simply need to trim the junk of both ends of the string
MyGUID = Mid(MyGUID, 8, 36) 'staring at the 8th position, return 36 characters
'the string will now contain the following
'EXAMPLE: MyGUID = "E6919771-152B-463D-AC48-FFA22AB088FC"
'the string MyGUID can now be used in Form.Filter or Form.RecordSource properties, or others
'Example One: Open Form with filter
stLinkCriteria = "[GUID]='" & MyGUID & "'"
DoCmd.OpenForm "MyForm", , , stLinkCriteria
'Example Two: Set Form.RecordSource
DoCmd.OpenForm "MyForm"
Forms![MyForm].RecordSource = "Select * From MyTable Where [GUID]='" & MyGUID & "'"
End Function
Private Function InShort()
Dim MyGUID As String
MyGUID = StringFromGUID(Me![Guid])
MyGUID = Mid(MyGUID, 8, 36)
DoCmd.OpenForm "MyForm"
Forms![MyForm].RecordSource = "Select * From MyTable Where [GUID]='" & MyGUID & "'"
End Function