473,396 Members | 2,061 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,396 software developers and data experts.

Transferspreadsheet & Path as String

I'm using Access 2007.

I'd like to create a dynamic string variable to the use in the Transferspreadsheet function in Access. The string will be the location/filename for the spreadsheet.

The string will look something like "\\Directory\Sub1\Sub2\Wk1\Excel.xls"

I'd like to create the string with code. Example:
DirStr = "\\Directory\Sub1\Sub2\Wk" & WeekNumber & "\" & "Excel.xls"
(where WeekNumber is an interger that represents a week as a number)

The code works fine when I do not include the WeekNumber variable. But when I do this (whether the directory exists or not). The WeekNumber variable is ignored altogether and the path isn't created correctly.

What am I doing wrong? I have a suspicion it's something simple and easy to fix.

Thanks in advance.

CC
Feb 11 '10 #1
5 3190
ADezii
8,834 Expert 8TB
Are you creating each Folder beforehand or dynamically?
Feb 12 '10 #2
I haven't tried creating the folder dynamically. I've only tried creating the Wk1 folder prior to running the code. But I still get the same problems. I think it's something concatening "\" with the rest of the string for the file location.
Feb 12 '10 #3
NeoPa
32,556 Expert Mod 16PB
Check out the value of WeekNumber before using it. When you know what the value is you'll have a much better understanding of your issue.

See below for some tips :
One of the most popular (frequently occurring rather than best liked) problems we get is with SQL strings being manipulated in VBA code.

The reason this is so difficult is that all the work is being done at a level of redirection. What I mean by this is that the coder is never working directly with the SQL itself, but rather with code which in turn, is relied on to produce the SQL that they are envisaging is required. It's rather similar to the problems coders have historically had dealing with pointers.

Anyway, a technique I often suggest to coders struggling with this (at any level. This happens to experienced coders too.) is to use either the MsgBox() function, or Debug.Print into the Immediate Pane of the debugger window, to display the value of the SQL in the string before using it (That's assuming you're not good with debugging generally. Personally I would trace to the line, then display the value prior to allowing execution of the string - See Debugging in VBA). It's really much easier to appreciate what a SQL string is meant to do, and where there may be problems, when you can see it in its entirety, and in its true form, rather than as the code is about to create it.
Feb 12 '10 #4
It appears to be working now. But to follow-up, the value of Week is something like 201002 (year & weeknumber).

But thanks so much for your help. And the tips on troubleshooting!
Feb 15 '10 #5
NeoPa
32,556 Expert Mod 16PB
No worries.

From your response, and your earlier posts, I suspect it's now working because there is a valid value in WeekNumber, whereas before (if my reading of the situation is correct) there was none. The code may need to check that the value is available before executing anything which depends on its availability.

Anyway, I'm pleased you've made progress :)
Feb 16 '10 #6

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
2
by: Hank | last post by:
Hello, I use TransferSpreadsheet on a daily basis using a Table as a datasource. I was under the impression from reading Help that you could also use a Query as the datasource. This is my code:...
4
by: Google Boy of Company C | last post by:
Hi Does anyone know why there seems to be a file name limit of 60 characters in Transferspreadsheet. I am exporting some records and this is giving me severe grief. I keep getting a message...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
3
by: RZ15 | last post by:
Hi, I'm going to be giving many people an access database file with a switchboard with quite a few essential queries (query-by-form) so that they can pull data whenever they want. I have a button...
2
by: RZ15 | last post by:
Hi, I am trying to use the transferspreadsheet command to transfer a table into an excel file i have. I'm using the following code: Private Sub cmdOK_Click() 'Run Make-Table query...
5
by: D.Stone | last post by:
I'm getting a problem with importing an Excel spreadsheet into a table in a SQL Server 2000 back-end. I'm doing this in VBA in an onClick event proc in an Access 2003 project. The target table's...
1
by: troy_lee | last post by:
Here is my code: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "C: \Databases\RMA Database Redesign\ParetoTemplate2.xls" Access says that I need to assign a file path or name. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.