and more important is the address of the cell you're trying to fill correct at time of inserting the copytext
Main Topics
Browse All TopicsVB6 SP4
WIN 2000
EXCEL 2000
ACCESS 2000
I keep getting an error on the line below. as indicated.
I HAVE TRIED CHANGING THE STRINGS TO VARIANTS BUT IT DOES NOT HELP....
I'm trying to import(map) data from Access to Excel via listbox field selections.
This field go to that column etc.............
' ACCESS TO EXCEL
' reopen access
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim db_name As String
Dim Copycells As Variant
'db_name = Text2.Text
db_name = Text1.Text
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OL
"Data Source=" & db_name & ";" & _
"Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
' ============== reopen excel Destiniation ==========================
'EFile = CommonDialog1.FileName
Text2.Text = EFile ' efile is a variable
Set oDest = CreateObject("Excel.Applic
oDest.Visible = True
oDest.workbooks.Open EFile
' ============== reopen excel ==========================
rs.Open (List1), conn, , , adCmdTable ' all records
Dim lastSourceRow As Long
Dim lastDestRow As Long
lastSourceRow = rs.RecordCount 'oSource.SHeets(List1.Text
lastDestRow = oDest.SHeets(List4.Text).U
' ReDim Copycells(lastSourceRow - 1) As Variant
' oDest.Visible = True
' NEW CODE **************************
'Dim CopyText As String
Dim CopyText As Variant
Dim str1 As String
Dim sourcedest As String
Dim x2 As Variant
'Dim strUnknown As String
'Dim strNext As String
' start Excel to Access import
Do While Not rs.EOF
x2 = lastDestRow + 1
lastDestRow = x2
oDest.ActiveCell.Offset(1,
oDest.ActiveCell.EntireRow
For x = 1 To lvwMap.ListItems.Count
str1 = lvwMap.ListItems.Item(x).L
sourcedest = lvwMap.ListItems.Item(x).L
CopyText = rs.Fields(str1).Value
' ERROR ON THE LINE BELOW RUNTIME ERROR 13 TYPE MISMATCH
oDest.SHeets(List4.Text).R
Next x
x2 = x2 + 1
rs.MoveNext
Loop
rs.Close
conn.Close
' NEW CODE **************************
MsgBox "Acces Data Import is Completed !"
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Yes,
and what did ring on a bell from both of you is the .Value issue
I have yet to figure it out but,
The index value on the listbox selection was not correct.
I changed the .text to
FROM :
sourcedest = lvwMap.ListItems.Item(x).L
TO:
sourcedest = CInt(lvwMap.ListItems.Item
I was puliing in the value text not the actual index value....
Thanks
I hope this was it..
Still playing around...
fordraiders
Business Accounts
Answer for Membership
by: bruintjePosted on 2004-02-25 at 11:43:07ID: 10453529
are you sure it's containing a *known* value?
ange(oDest .Workbooks (1).Sheets (List4.Tex t).Cells(x 2, CInt(sourcedest)), oDest.Workbooks(1).Sheets( List4.Text ).Cells((x 2), CInt(sourcedest))) = CopyText
if yes then what happens if you try it like
oDest.Sheets(List4.Text).R