Modify a record

JBurlison

Registered User.
Local time
Today, 05:33
Joined
Mar 14, 2008
Messages
172
Im getting "operation is not supported for this type of object" for rsCustomer.FindFirst "[ID] = '" & ID & "'". any Ideas? its been a while since I have touched access 2008 or so.
Code:
    Private Sub selectId_Click()
    Dim fDialog As Office.FileDialog
    Dim varFile As Variant
    Dim dbObj As DAO.Database
    Dim rsCustomer As DAO.Recordset
    
    Set dbObj = CurrentDb
    Set rsCustomer = dbObj.OpenRecordset("customer")
    rsCustomer.FindFirst "[ID] = '" & ID & "'"
    
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog
      .AllowMultiSelect = False
      .Title = "Please select Scan of Customers ID"
      If .Show = True Then
         For Each varFile In .SelectedItems
             rsCustomer.Edit
             rsCustomer("id_scan").Value = varFile
             rsCustomer.Update
         Next
      Else
         'cancel
      End If
   End With
    If id_scan <> Null Then
        idDisplay.Picture = id_scan
    End If
End Sub
 
Some recordsets don't support FindFirst. More efficient anyway would be:

Set rsCustomer = dbObj.OpenRecordset("SELECT * FROM customer WHERE [ID] = '" & ID & "'")

Then your recordset only contains matching records, if any.
 
Some recordsets don't support FindFirst. More efficient anyway would be:

Set rsCustomer = dbObj.OpenRecordset("SELECT * FROM customer WHERE [ID] = '" & ID & "'")

Then your recordset only contains matching records, if any.

Im getting "Data type mismatch in criteria expression" with that. I tried selecting from another column and cstr.

EDIT: I dont know if this matter but on a side note, I am attempting to edit the record the form is currently on. I have a button that allows you to select the persons ID and it is displayed on the form (this function).
 
Last edited:
If ID is numeric try:

Set rsCustomer = dbObj.OpenRecordset("SELECT * FROM customer WHERE [ID] = " & ID)
 

Users who are viewing this thread

Back
Top Bottom