Hi, all -
I am modifying an existing database and replacing an early text field with an autonumber. The field name is the same as previously with with the values and data type being different. The field in question is PTID
In the previous version, I had code that worked fine to determine the existence of a record through search criteria and if such a record didn't exist, one would be created. The search criteria comes from the value in a lookup combo box.
With the values and the data type being different, I'm getting a data type mismatch in criteria expresson error, but not sure how to correct it.
Here is the code:
Any throughts on how to correct this would be appreciated.
Thanks.
I am modifying an existing database and replacing an early text field with an autonumber. The field name is the same as previously with with the values and data type being different. The field in question is PTID
In the previous version, I had code that worked fine to determine the existence of a record through search criteria and if such a record didn't exist, one would be created. The search criteria comes from the value in a lookup combo box.
With the values and the data type being different, I'm getting a data type mismatch in criteria expresson error, but not sure how to correct it.
Here is the code:
Code:
Private Sub cbxResidentLookup_AfterUpdate()
On Error GoTo cbxResidentLookup_AfterUpdate_Err
Dim strCriteria As String ' This is the argument to the FindFirst method.
Dim rstClone As Object ' Recordset used to search.
Dim strID As String ' The PtID# to search for.
Dim Count As Integer
Dim n As Integer
Dim rs as Recordset
' Build the criteria.
strID = Me.cbxResidentLookup
strCriteria = "[PtID] = '" & strID & "'"
Count = 0
n = DCount("PtID", "tblResGeneralClinical", strCriteria)
Perform the search.
Count = Count + n
If Count = 0 Then
MsgBox "A clinical record has been added for this patient."
With rs
DoCmd.GoToRecord , , acNewRec
Me.PtID = strID
End With
End If
Any throughts on how to correct this would be appreciated.
Thanks.
Last edited: