Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Access 2000

Status
Not open for further replies.

edderic

Programmer
May 8, 1999
628
import Table (access2000) with VB-code to a external access2000 database,what's wrong with this code :<br>
<br>
<br>
Private Sub Command1_Click()<br>
<br>
Dim cnn1 As ADODB.Connection<br>
Dim cmdQuery As ADODB.Command<br>
Dim strCnn As String<br>
Dim Rs1 As ADODB.Recordset<br>
Dim prm As ADODB.Parameter<br>
<br>
Dim First, UserPath As String<br>
On Error GoTo ErrorHandler<br>
<br>
sTable = List2.List(0)<br>
strCnn = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=&quot;<br>
strCnn = strCnn & sTmp<br>
<br>
Set cnn1 = New ADODB.Connection<br>
cnn1.Open strCnn<br>
<br>
Set cmdQuery = New ADODB.Command<br>
Set Rs1 = New ADODB.Recordset<br>
Set cmdQuery.ActiveConnection = cnn1<br>
<br>
SelectString = &quot;SELECT * INTO&quot;<br>
FromString = &quot;FROM&quot;<br>
FromSource = sTmp<br>
NewTable = Text7.Text<br>
<br>
SQLtext = SelectString & Space(1) & &quot;[&quot; & Destination & &quot;]&quot; _<br>
& &quot;.&quot; & NewTable & Space(1) & FromString & Space(1) _<br>
& &quot;[&quot; & FromSource & &quot;]&quot; & &quot;.&quot; & sTable<br>
<br>
cmdQuery.CommandText = SQLtext<br>
<br>
Set Rs1 = cmdQuery.Execute()<br>
<br>
If Err.Number = 0 Then<br>
MsgBox &quot;De Tabel is geimporteerd&quot;, vbOKOnly, &quot;Bericht aan gebruiker&quot;<br>
End If<br>
<br>
cnn1.Close<br>
Exit Sub<br>
<br>
<br>
<br>
ErrorHandler:<br>
Select Case Err.Number<br>
Case Else<br>
<br>
Msg = &quot;Unexpected error #&quot; & Str(Err.Number)<br>
Msg = Msg & &quot; occurred: &quot; & Err.Description<br>
<br>
MsgBox Msg, vbCritical<br>
<br>
End Select<br>
Resume Next<br>
End Sub<br>
<br>
Eric<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top