RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: ryguy7272 <ryguy7272@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 13:34:02 -0700
Well, that definitely gets me a little closer Klatuu. Yes, I knew about the
TransferSpread*** method, but with all of the other Access-related things
I'm thinking about right now, I guess I forgot about this option. Thanks for
refreshing my memory! So anyway, I created a Macro with two steps:
DeleteObject and TransferSpread***. I don't know enough about this to know
if I am doing this correct, but I feel I am not. I guess the DeleteObject
deletes the entire Table and then the TransferSpread*** will recreate the
Table and then suck in all the data from my Excel *** on the network drive.
This second part seems like it is working fine. I'm not sure if I should
delete that Table though. It seems like the references to this Table (such
as those links in the Form's Row Source) are getting pretty screwed up when
the Table is deleted and then recreated. Is there a way of using a Macro to
reference a Table, clear the Table, and the do the import? Also, I'm getting
the F1, F2, F3 stuff as column headers now! I think that is further screwing
up my whole process. In my Form, I have a few items in the ListBoxes in Row
Source such as:
SELECT DISTINCT tblTFI.Broker FROM tblTFI ORDER BY tblTFI.Broker;
I guess Access can't find the appropriate Column names, such as 'Broker'
because it is seeing F1, F2, etc. There must be a way around this, right.
Finally, thanks for the suggestion to use the =fGetUncPath("R:")
I'd like to try this method, however, I'm not sure where to put this
function. I know how to call a function in Excel, but in Access it must be
totally different. Can you please dispense a little more advice about how to
call this function?
Thanks for everything!!
--
RyGuy
"Klatuu" wrote:
The simplest way to import data into an Access table from Excel is to use the.
TransferSpread*** method. You can get the details in VBA Help.
As to UNC paths. In a multi user networked environment, you should always
use them instead of drive letter mapping.
If you have the code downloaded you referred to in your original post, it is
easy to find the UNC path for a drive litter. For example, if you want to
return the UNC path for drive R it would be:
=fGetUncPath("R:")
Also, to reverse the procedure, add this code to the module that has th
efGetUncPath function in it:
Function UNCDrive(strUNCName As String) As String
'Dave Hargis 9/05
'Returns Drive Letter for UNC drive mapping
Dim strAllDrives As String
Dim varDriveList As Variant
Dim lngDriveIndex As Long
Dim strCurrDrive As String
Dim strPathName As String
strAllDrives = fGetDrives
strAllDrives = Left(strAllDrives, Len(strAllDrives) - 1)
varDriveList = Split(strAllDrives, Chr(0))
lngDriveIndex = UBound(varDriveList) - 1
For lngDriveIndex = 0 To UBound(varDriveList)
strCurrDrive = varDriveList(lngDriveIndex)
If fDriveType(strCurrDrive) = "Network Drive" Then
strPathName = fGetUNCPath(Left(strCurrDrive, Len(strCurrDrive) -
1))
If strUNCName = strPathName Then
UNCDrive = strCurrDrive
Exit For
End If
End If
Next lngDriveIndex
End Function
If you pass it the UNC path, it will return the drive letter.
--
Dave Hargis, Microsoft Access MVP
"ryguy7272" wrote:
Originally I was thinking of using a macro to import the Excel *** into an
Access Table. Trouble is...I don't know Access all that well (very well
versed with Excel though). Maybe that is the way to go though. How can I
use VBA to create a table in Access, and import the data from a specific
Excel *** stored on a specific network drive? Or, how can I use a Table
that I have, clear out all data, and and import the data from a specific
Excel ***? The Excel *** is updated once per data, usually. And I set
up this database to allow us to create lots of dynamic Reports and Queries.
I just have to get the Excel data to flow from the Excel *** into the
Access table. I tried this earlier in the week using code from this site:
http://www.erlandsendata.no/english/index.php?t=envbadac
Most of the things there allow you to control Access from Excel. Would I be
better off controlling Excel from Access, such as Import data from a closed
workbook into Access? Does anyone know of good, simple, VBA code for this?
Again, I am much less versed in Access than I am in Excel.
Thanks for your patience!! I will get this thing working!!
--
RyGuy
"Beetle" wrote:
I've imported excel data into access many times, but I haven't tried to
use a spread*** as an external data source for queries, so I'm not
that familiar with it. I'll play around with that a bit on my end to see
how it works, but in the meantime, hopefully someone with more
experience ( i.e. - smarter than me :-) ) will pick up this thread
and give you an answer.
--
_________
Sean Bailey
"ryguy7272" wrote:
I used this:
\\AP-SVR-3\users\Excel List.xls\Main$
Excel List = name of Excel file
Main = Name of Excel *** that I need to link to
I tried to set it up through the Linked Table Manager, and it still doesn't
work. Does the space in the file name prevent it from working?
I can actually build the Report and the Query too, but I just can not see
the data displayed in the ListBox or in the ComboBox (tried it both ways).
There is just a lot of white spaces in the ListBox and ComboBox; the data
itself seems to be invisible. But, if I click on the first item in the
ListBox, and I know what it is only because I am very familiar with the data,
that 'criteria' is what Access uses to build my dynamic Queries and my
dynamic Reports. I wish there was some way to DISPLAY those elements of data
in the ListBox...
I would graciously welcome any other ideas.
Regards,
Ryan---
--
RyGuy
"ryguy7272" wrote:
OK, I agree. This is probably the way to go (my knowledge and experience in
this particular area is quite limited). Now, how do I use that UNC Path? Do
I put it in the Form? How? Do I use it in the code? Where? Please show me
how to implement this idea.
Regards,
Ryan---
--
RyGuy
"Beetle" wrote:
UNC paths don't use drive letters, so in your case the path would look
something like;
\\AP-SVR-3\users\ExcelFiles\YourExcelFile.xls
--
_________
Sean Bailey
"ryguy7272" wrote:
Issue with UNC Path (I think). Trying to build Dynamic Report, using SQL
Just recently I encountered a problem that I’ve never dealt with before. I
think it has to do with something called UNC Path. If you are not frightened
at this point, please read on…
I got some awesome help from this Access DG recently, and I think I am close
to resolving the issue, but I am not quite there yet, and I need a little
more of a push to get there…please bear with me.
I am trying to Link to an Excel file on a network drive and build a Report
and a Query, using a Form. Pretty simple, right (eyes rolling right now…).
Anyway, after some major frustration, I think I am pretty close to getting
this wrapped up, and I’d love to finish before I get out of here for the
weekend.
In Access, I went to File > Get External Data > Link Tables
Then, I used the Wizard to pick the right ***. Now I have a Form with a
ComboBox that has this logic in the Row Source:
SELECT DISTINCT Main.Broker FROM Main ORDER BY Main.Broker;
This code is behind the Form:
Option Compare Database
Option Explicit
Private Sub cmdApplyFilter_Click()
Dim strBroker As String
Dim strProd As String
Dim strStatus As String
Dim strFilter As String
' Build criteria string for Broker field
If IsNull(Me.cboBroker.Value) Then
strBroker = "Like '*'"
Else
strBroker = "='" & Me.cboBroker.Value & "'"
End If
' Build criteria string for Product field
If IsNull(Me.cboProd.Value) Then
strProd = "Like '*'"
Else
strProd = "='" & Me.cboProd.Value & "'"
End If
' Build criteria string for Status field
If IsNull(Me.cboStatus.Value) Then
strStatus = "Like '*'"
Else
strStatus = "='" & Me.cboStatus.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Broker] " & strBroker & " AND [Prod] " & strProd & " AND
[Status] " & strStatus
' Apply the filter and switch it on
DoCmd.OpenReport "SelReport", acPreview, , strFilter
With Reports![SelReport]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub cmdRemoveFilter_Click()
On Error Resume Next
' Switch the filter off
Reports![SelReport].FilterOn = False
End Sub
The code came from here:
http://www.fontstuff.com/access/acctut19.htm
I received some great help from the Access Programming DG and began to think
that the issue was related to something called a UNC Path. I did some
research and found the site below:
http://www.mvps.org/access/api/api0003.htm
I found that there are several UNC paths on my firm’s network. Some are as
follows:
Removable drive : A:\
Local drive : C:\
Removable drive : F:\
Network drive : H:\
UNC Path : \\AP-SVR-3\users
I can link the Excel file to a local drive, like my C-drive, and everything
works fine. However, when I put the Excel file on our firm’s network drive,
I can’t get Access to find the data source!!
I am interested in mapping my Form, or Query, or whatever to an Excel file
on the H-drive, which I guess is UNC Path : \\AP-SVR-3\users
I found the information on this site useful:
http://support.microsoft.com/kb/328440
Anyway, that’s the background. I can link the Excel file to a local drive,
like my C-drive and everything works fine. However, when I put the Excel
file on our firm’s network drive, Access seems to struggle to find the data
source, sometimes pausing for several minutes, and when if finally finishes
(I’m not even sure what it is doing), I try to find my data in the drop down
menu of the ComboBox and I see nothing but blanks. After struggling with
this project for a couple of weeks, I honestly think I am close, but I’m not
exactly sure what to do at this point. Also, I think it has to do with the
UNC Path, but I’m not sure about that…I never heard of a UNC Path until
yesterday.
This is the drive that I want to save the Excel file on:
Network drive : H:\
UNC Path : \\AP-SVR-3\users
I think somehow I have to point Access to this spot, perhaps within the code
(above). As I stated I have the Row Source pointing to the Excel file called
'Main', but Access isn't able to find the data source.
I’ve gotten some great help on this one, but I still can’t get this thing to
work. If you’ve dealt with this type of issue before, and you know what to
do, please let me know.
Regards,
Ryan---
--
RyGuy
- Follow-Ups:
- References:
- Issue with UNC Path (I think). Trying to build Dynamic Report
- From: ryguy7272
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: Beetle
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: ryguy7272
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: ryguy7272
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: Beetle
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: ryguy7272
- RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- From: Klatuu
- Issue with UNC Path (I think). Trying to build Dynamic Report
- Prev by Date: Re: Master form and subform
- Next by Date: Re: Code dependant on if a form is open or closed
- Previous by thread: RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- Next by thread: RE: Issue with UNC Path (I think). Trying to build Dynamic Report
- Index(es):