Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Unanswered: Access table is not recognized when referring it from VBA

    Hi,

    I am facing some issues when trying to fetch records from an Access table. Below is the VB code, coded in an access file where the table BkupData exist, the data base is 'Database2' which is in C drive. The select query giving error message that the table 'MyUserID.BkupData' is undefined, but the table BackupData exists in the same document from where I am running this VBA code. I dont know how to set up the database 'Database2' for this Query. The recordset 'objRs' contains the records fetched from a mainframe DB2 table.

    Set adoJetConnection = CreateObject("ADODB.Connection")
    adoJetConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
    "Data Source=C:\Database2.accdb;Persist Security Info=False"
    adoJetConnection.Open

    ' ADO command object to insert rows into Access database.

    Set adoJetCommand = CreateObject("ADODB.Command")
    Set adoJetCommand.ActiveConnection = adoJetConnection
    adoJetCommand.CommandType = adCmdText23996

    objRs.MoveFirst
    Do Until objRs.EOF
    objCmd.CommandText = " SELECT * FROM BkupData " & _
    " WHERE RSC_STK_NUM = '" & objRs.Fields ("RSC_STK_NUM").Value & "'"
    objCmd.CommandType = adCmdText
    Set objRecst = objCmd.Execute

    ----
    ---
    Loop

    Your help is greatly appreciated. Thanks in Advance
    Last edited by sarav_cit; 11-03-11 at 14:01.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •