473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help - Access 2003 VBA - range values

Hi,

I'm trying to debug some code where I'm trying to retrieve particular ranges in an excel sheet into an Access table, depending on the user selection of the range name in a combo box with a list of range names.

I have already named the ranges I need in the target Excel sheet as follows :

range1 (where range1 =$A$1:$E$10

range2 = $H$1:$L$10 and so on

The combo box control is named Combo1 on a form called select_range

Once the user opens the form and clicks on range1 and then OK, The row source for the combo box is a table containing the rangenames (text fields).

So, if the user clicks on the first value in combo box, range1 where range1 = Sheet1!range1, it should replace the rng String with the value Sheet1!range1 in the command below.

Alernatively, if the user clicks range2, it should replace this with Sheet1!range2 in the command below.


I want the following command executed :

Private Sub Command0_Click()

Dim rng as String

rng = Me.Combo1.Column(0)

DoCmd.TransferSpreadsheet transfertype:=acImport, SpreadsheetType:=5, _
tablename:="Test", Filename:="c:\test.xls", _
Hasfieldnames:=True, Range:="rng"


End Sub

When I execute this, I get a Run-time error 3011, where access says it cannot find the object 'rng".

Can anyone here help debug this ? Any help here would be appreciated.

Thanks in advance.
Mar 9 '07 #1
2 2395
r035198x
13,262 8TB
Moved to access forum.
Mar 10 '07 #2
ADezii
8,834 Expert 8TB
Hi,

I'm trying to debug some code where I'm trying to retrieve particular ranges in an excel sheet into an Access table, depending on the user selection of the range name in a combo box with a list of range names.

I have already named the ranges I need in the target Excel sheet as follows :

range1 (where range1 =$A$1:$E$10

range2 = $H$1:$L$10 and so on

The combo box control is named Combo1 on a form called select_range

Once the user opens the form and clicks on range1 and then OK, The row source for the combo box is a table containing the rangenames (text fields).

So, if the user clicks on the first value in combo box, range1 where range1 = Sheet1!range1, it should replace the rng String with the value Sheet1!range1 in the command below.

Alernatively, if the user clicks range2, it should replace this with Sheet1!range2 in the command below.


I want the following command executed :

Private Sub Command0_Click()

Dim rng as String

rng = Me.Combo1.Column(0)

DoCmd.TransferSpreadsheet transfertype:=acImport, SpreadsheetType:=5, _
tablename:="Test", Filename:="c:\test.xls", _
Hasfieldnames:=True, Range:="rng"


End Sub

When I execute this, I get a Run-time error 3011, where access says it cannot find the object 'rng".

Can anyone here help debug this ? Any help here would be appreciated.

Thanks in advance.
I'm pretty sure that the problems lies with the Sheet1! qualifier. Simply specify the Range Name without the qualifier, e.g. rng = "Range1", and you should be OK. Let me know how you make out.
Mar 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Jeff Wagner | last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: Michael John | last post by:
Dear Oracle Developers, my task is to make up a Oracle View from a Pivot table in MS Access. Given are two tables to join: T_FIRM: FIRM_ABBR VARCHAR2(3 BYTE), FIRM_LONG ...
3
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
11
by: bbasberg | last post by:
Hello, I have been struggling with this problem for DAYS and have googled my heart out as well as reading any books I could get my hands on but I cannot find any specific references to my problem....
2
by: bbasberg | last post by:
I have been working hard to clean up my code but I am still wondering why all incoming records go to the "AddNew" part of the IF statement and never to the Edit alternative. I believe that it must be...
2
by: keithsimpson3973 | last post by:
I have a program built in Visual Basic 6. It uses an Access 2003 database. My report selection form in vb6 has 2 date pickers for start date and end date. The report is an Access report. When the...
7
by: AkosBeres | last post by:
I’m in the process of setting a sample local Access table called "Fruits" to store data in the following sample fileds: Week Amount Description Version or sequence The data will be loaded into...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.