[RESOLVED] MS Access - GUID in recordset - data type conversion error
I'm having trouble assigning a GUID value using a RecordSet, using MS Access. I get a data type conversion error when trying the below code. What is the correct way to assign a GUID value to a GUID field in a recordset?
Code:
Dim rst As Recordset
Set rst = Me.BehaviorDetail_subform.Form.RecordsetClone
MsgBox StringFromGUID(Me.FormID.Value) 'shows the correct guid string, so the value is there
If rst.RecordCount = 0 Then
'add new time records for row
rst.AddNew
rst!FormID = Me.FormID '<-- problem is here. FormID is GUID type in recordset, Me.FormID is a bound textbox that has a valid GUID object
rst!TimeID = 1
rst.Update
......
Re: MS Access - GUID in recordset - data type conversion error
Just a guess, maybe try Me.FormID.Text?
Re: MS Access - GUID in recordset - data type conversion error
I figured it out. The Guid String returned was in the format of "{guid {...}}", and the recordset just needs the Guid string value enclosed with "{...}" only, so if you just remove the "{guid ... }" part in the string, it works.