Recordset.find fetching first record..my ID and StrCustomer data type are auto number

CFO PIDC 21 Reputation points
2022-06-03T09:51:41.497+00:00

Private Sub LoadCustomer(strCustomerID As String)
' This will retrieve the customer info and populate the data on the form. Note that
' the recordset is immediately closed once the info is retrieved.

Dim rs_customer As ADODB.Recordset

On Error GoTo Err_LoadCustomer

Set cnn = CurrentProject.Connection
Set rs_customer = New ADODB.Recordset

rs_customer.Find "ID = '" & strCustomerID & "'"

Debug.Print ID, textf, numf, datef
If rs_customer.EOF Then
Beep
MsgBox "Customer record not found. CustomerID = " & strCustomerID
GoTo Exit_LoadCustomer
End If

With rs_customer
  CompanyName = !textf
  'textf = !CompanyName
  ContactName = !numf
  'ContactTitle = !ContactTitle
  'Address = !Address
  City = !datef
  'Region = !Region
  'PostalCode = !PostalCode
  'Country = !Country
  'Phone = !Phone
  'Fax = !Fax
End With
Microsoft 365 and Office | Access | Development
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.