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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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