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
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