DAO FindFirst Recordset - Excel Data Base

vinniz

New Member
Joined
Jul 25, 2017
Messages
1
Hey, Guys
Please, Can you help with an DAO issue?
I need to use an Excel data base instead of an Access data base.
I am having a problem with this command: Recordset.FindFirst
I guess that the syntax is not ok.

The problem: rs.FindFirst "[FirstName] = " & Chr(34) & Resp & Chr(34)

Here is the code:

Code:
Option Explicit
Private Add2 As String
Private Name2 As String
Private db As DAO.Database
Private rs As DAO.Recordset



Sub DefineNamesFiles()
   Add2 = "C:\Users\vpoliveira\Desktop\"
   Name2 = "base.xlsx"
End Sub


Sub EditDataBase()
  Dim Resp As String
  Call DefineNamesFiles


  Set db = OpenDatabase(Add2 & Name2, False, False, "Excel 12.0")
  Set rs = db.OpenRecordset("Plan1$")
  
  Resp = InputBox("Inform the name")
  
  '***************************************************
  rs.FindFirst "[FirstName] = " & Chr(34) & Resp & Chr(34)
  '***************************************************
 
  '-------------------------------------------------------------------
  If rs.NoMatch = True Then
    MsgBox "Not Found", vbOKOnly + vbInformation, "DAO information"
    Exit Sub
  Else
    'Edit data in recordset
    rs.Edit
      rs!FirstName = InputBox("Digite o novo nome")
      rs!City = InputBox("Digite a nova cidade")
      rs!Country = InputBox("Digite o novo nome do paÃ*s")
    'Update data
    rs.Update
  End If
  '-----------------------------------------------------------------


MsgBox "Success!"
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing


End Sub

Thanks a lot!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,381
Messages
6,124,614
Members
449,175
Latest member
Anniewonder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top