Data Type Mismatch in LookUp with GUID

jleval

Registered User.
Local time
Yesterday, 19:20
Joined
May 16, 2012
Messages
53
I have a database that is using GUIDs as Primary Keys. Unfortunately, when I tried to create a lookup combo box in my form, I got a datatype mismatch. No matter what I try, I cant seem to get around this problem, and my boss insists on using GUIDs instead of autonumbers. Any ideas on how to get around this.
 
Do you mean you are trying to put a combo box on which, when a value is selected, goes to that record? if so you will likely have to change the code for the combo box to this (using your real field names and combo box name):
Code:
Private Sub Combo4_AfterUpdate()
    ' Find the record that matches the control.
    Dim rst As DAO.Recordset
    Dim db As DAO.Database
    Set db = CurrentDb
    Dim strGUID As String
    
    
    Set rst = Me.Recordset.Clone
    Do Until rst.EOF
        strGUID = Mid(rst!MyID, 7)
        If Right(strGUID, 2) = "}}" Then
            strGUID = Left(strGUID, Len(strGUID) - 1)
        End If
        If strGUID = Me.Combo4 Then
            Me.Bookmark = rst.Bookmark
            Exit Sub
        End If
        rst.MoveNext
    Loop
End Sub
 
Thank you so much. You provided an answer before the microsoft answers site did. You are awsome
 

Users who are viewing this thread

Back
Top Bottom