Dealing with Replication ID data types on a form: Trouble finding records on a form with a ComboBox using a Replication ID ("type mismatch" error)
Posted on 2003-11-29
I have an Access 2000 database with a table (Tbl_People) whose Primary Key (PeopleID) is an Autonumber with the field size set to Replication ID (to create a GUID).
I created a form (frm_People), and I would like to have a combobox that finds a record on the form based on the value of the combobox. However, I receive a "type mismatch" error when I select a value from the combobox.
Here is the code that the wizard generated to find the record: (the combobox is cboRcdSelect, the Replication ID field is PeopleID)
Private Sub cboRcdSelect_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PeopleID] = " & Str(Nz(Me![cboRcdSelect], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
The problem seems to be that I can't convert cboRcdSelect to a string, which is where the "type mismatch" error comes from.
Does anybody know how I can deal with Replication ID values on a form like this? I will need to create over 15 forms with similar structures, so I am looking for a flexible, relatively uncomplicated way to fix it.
I can't continue working on the project until I figure this out, so I would greatly appreciate any help.
PS - Would it be easier to create a Function that creates the GUID and insert it into the primary key field as a string through the form? I know how to do that, but the Replication ID seems convenient and I'd like to learn how to work with it more - but I'm open.