If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Access table is not recognized when referring it from VBA

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-03-11, 12:58
sarav_cit sarav_cit is offline
Registered User
 
Join Date: Oct 2011
Posts: 3
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 13:01.
Reply With Quote
Reply

Tags
access, vba access

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On