help with this function

N

nokia3650

can u help me with these:

Public Function ImportAsbisxxx()

Dim db As Database
Dim rs As Recordset
Dim kom As Integer
Dim sqlupit As String
Dim imetabele As Variant

Set db = CurrentDb()
kom = 2
sqlupit = "SELECT Sheetovi.F1 as ime_sheeta FROM Sheetovi WHERE
Sheetovi.AutoBroj=" & kom
Set rs = db.OpenRecordset(sqlupit)
imetabele = rs!ime_sheeta & "!A6:I250"

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False, imetabele

End Function

and it doesnt work.
if i change :

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False, imetabele

to

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False,
"sheetname!A6:I250"

then it works.

i also looked if the sql gives me the right name and it is all ok

is the problem in data type of imetabele

thx
 
O

OfficeDev18 via AccessMonster.com

I think you forgot one line of code.

Set rs = db.OpenRecordset(sqlupit)
imetabele = rs!ime_sheeta & "!A6:I250"

needs a line saying

Set rs = db.OpenRecordset(sqlupit)
rs.MoveFirst
imetabele = rs!ime_sheeta & "!A6:I250"

Hope this helps,

Sam
 
M

Marshall Barton

nokia3650 said:
can u help me with these:

Public Function ImportAsbisxxx()

Dim db As Database
Dim rs As Recordset
Dim kom As Integer
Dim sqlupit As String
Dim imetabele As Variant

Set db = CurrentDb()
kom = 2
sqlupit = "SELECT Sheetovi.F1 as ime_sheeta FROM Sheetovi WHERE
Sheetovi.AutoBroj=" & kom
Set rs = db.OpenRecordset(sqlupit)
imetabele = rs!ime_sheeta & "!A6:I250"

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False, imetabele

End Function

and it doesnt work.


Your logic looks ok, but something about the sheetname from
the recordset is not good. On the other hand, "it doesnt
work" doesn't provide any clues as to what might be wrong.
At this point all I can suggest is that you add a break
point to make sure the imetabele string is exactly as it's
supposed to be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top