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

DIR(Filename) Question

25
Whys does the second "If Len(Dir(Filename)) > 0 Then" function not work in this code, the first one is ok. The files DO exist and both should return 'true'. If I REM the second IF THEN, ELSE, ENDIF statements, it loads the pdf file ok!

Private Sub Form_Current()

' Update Cost Sheet, Check Sheet and drive History data on NCR change

Dim db As Database
Dim rs As Recordset
Dim StrSQL As String
Dim CostSheetPath As String
Dim CheckSheetPath As String
Dim SerialNum As String
Dim Product As String
Dim Filename

Product = Nz(Forms!NCR![ProductCombo])

Set db = CurrentDb
StrSQL = "SELECT [Product Table].[Check Sheet Path], [Product Table].[Cost Sheet Path]FROM [Product Table]WHERE [Product Table].[Product/Service]= '" & Product & "'"

Set rs = db.OpenRecordset(StrSQL)

If rs.EOF = False Then

CostSheetPath = Nz(rs![Cost Sheet Path])
CheckSheetPath = Nz(rs![Check Sheet Path])
Else
CostSheetPath = ""
CheckSheetPath = ""

End If

SerialNum = Nz(Forms!NCR![Serial Number])


' Load Cost Sheet into Form if it exists otherwise hide it

Filename = CostSheetPath + SerialNum + ".xls"

If Len(Dir(Filename)) > 0 Then ' Returns True

CostSheet_TAB.Visible = True
CostSheet.Visible = True
CostSheet.SourceDoc = Filename
CostSheet.Action = acOLECreateLink


Else

' Hide CostSheet TAB
CostSheet_TAB.Visible = False

End If



' Load Check Sheet into Form.

Filename = CheckSheetPath + SerialNum + ".pdf"

If Len(Dir(Filename)) > 0 Then ' Does not return True

CheckSheet_TAB.Visible = True
CheckSheet.Visible = True
CheckSheet.LoadFile Filename
CheckSheet.setShowToolbar (False)
CheckSheet.Height = 10000
CheckSheet.Width = 12000
CheckSheet.setView ("FullScreen")

Else

CheckSheet_TAB.Visible = False

End If


' close recordset

rs.Close

Set db = Nothing
Set rs = Nothing

End Sub
Feb 18 '08 #1
3 2752
Delerna
1,134 Expert 1GB
Shouldn' t these
Expand|Select|Wrap|Line Numbers
  1. ...
  2. Filename = CostSheetPath + SerialNum + ".xls"
  3. ...
  4. Filename = CheckSheetPath + SerialNum + ".pdf"
  5. ...
  6.  
be

Expand|Select|Wrap|Line Numbers
  1. ...
  2. Filename = CostSheetPath & SerialNum & ".xls"
  3. ...
  4. Filename = CheckSheetPath & SerialNum & ".pdf"
  5. ...
  6.  
Feb 18 '08 #2
Delerna
1,134 Expert 1GB
Don't forget you can set breakpoints so the code stops during execution and you can hover the mouse over variables and see their contents

You can even make a change in you code while the code has stoped at the breakpoint and then drag the execution point to the line before the change and continue execution from there. Saves stopping and restarting the program everytime just to make a change and see the effects.
I discovered that trick by accident one day while puzzling over a bug and fooling around with the mouse while I was thinking
Feb 18 '08 #3
Codebug
25
Solved the problem

Id forgotten that i had set another event to load the pdf.


In fact the path in th above code didnt exist, but I was fooled because it loaded the pdf ok!
Feb 18 '08 #4

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

Similar topics

7
by: JaNE | last post by:
hello and please excuse my clumsy english. I'm really fresh in php (just want to make one small script for myself, haven't fount such on net) and now I'm struggling with "calling one file from...
5
by: build | last post by:
G'day All, I have a problem with this loop. There are a number of .txt files in 'myPath'. tmpFile = Dir(myPath & "\*.txt") 'PROCESS FOLDER Do Until tmpFile = "" <lottsa code> <too much to...
1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
4
by: Ron Nolan | last post by:
Re: Access 2000 According to the help, to loop through a folder, you use code like this: ' Returns filename with specified extension. If more than one *.ini ' file exists, the first file...
3
by: Lumpierbritches | last post by:
I'm trying to move my images from my main folder to an image folder for the database to store pictures of animals. I borrowed code that works great if I put all the images in the main folder where...
10
by: Hughes | last post by:
Hi, I would like to get the filename from a folder by using C language. For example, in path /Users/abc/Desktop/xyz/ there is a file named "test.s" (file "test.s" is inside folder "xyz"). How...
2
by: bidalah | last post by:
Hi, Following is a simple version of my now non-working code: hihi = Dir("c:\burn2\*.*", FileAttribute.Normal) Do While Len(hihi) > 0 hoho = hehe hihi = Dir() Loop
4
by: Wernerh | last post by:
Hi, I have written my application and given the text files a dir to save to. Is there a way that that dir would read as a wildcard wherever I install it to? Example I have the drive path listed as...
32
by: ramesh54 | last post by:
Hello All, I have a small problem in reading the filename of a file. I would like to have a script which could read my file and create the respective folders, The file to be read is as follows...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.