Archana
Archana

Reputation: 37

Transfer Spreadsheet to Access Database with VBA

I have a browse button and pick and place the file name and path in textbox5. I need to use the same value in my file name but it does not work. It throws:

Run Time Error 2522- The action or method requires a File Name argument

Private Sub Command10_Click()
  Dim dbs As DAO.Database
  Dim td As DAO.TableDef
  Dim fileName As String

'set current database
 Set dbs = CurrentDb

 Me.Text5 = fileName

DoCmd.TransferSpreadsheet acImport, , "tblS3DimportTemp", fileName, True
 MsgBox "Data Uploaded!"

End Sub

Upvotes: 1

Views: 280

Answers (1)

Vityata
Vityata

Reputation: 43575

Instead of: Me.Text5 = fileName

write: fileName = Me.Text5

In many programming languages the left variable gets the value of the right one.

Upvotes: 2

Related Questions