468,771 Members | 1,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

If Dir - File lookup

I have written the following code to search for the right file depending on
the startup file for "Client Access". The menu database that I made will
load the correct config file specific for each "Thin Client". The problem
is that we also use PC's to run the "Client Access" program and under the
following script it will create a match and load the wrong WS file.

I read that you should not use the DIR function but that's that only way I
thought to search for the file name. The problem is that on every computer
there is a directory called ("C:\Program Files\IBM\Client
Access\Emulator\Private\") So I cant just search for the directory. The
thin clients are specific in location and I cant just have "C:\Program
Files\IBM\Client Access\Emulator\Private\" or else it will find it and then
I get a VB crash according to the runtime running on the Thin Client.

I have tried the DIR without the WS file however this is when I get the VB
runtime errors on the Thin Clients.

Is there an easier way to search for the file? I don't want the user to
have any choice, I want the script to do it for them. If the computer *.WS
file isn't found I want the error to display.

This is just the tip of the iceberg. I have 30 computers to add to the code
with another 30 printers.

You can reply here or through email at jo******@nospam.com change to
core.com.

Thanks in advance...Everyone here has made me a better Access user! I
appreciate any and ALL help...

Private Sub Shrdsp96_Click()
Dim strCmdLine As String
Const Q = """"

' Thin Client
If Dir("C:\Documents and Settings\property\My Documents\IBM\Client
Access\Emulator\private\SHRDSP68A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Documents and Settings\property\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP68A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\medical\My Documents\IBM\Client
Access\Emulator\private\SHRDSP69A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Documents and Settings\medical\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP69A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' PC
ElseIf Dir("C:\Program Files\IBM\Client
Access\Emulator\Private\shrdsp96a.ws") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Program Files\IBM\Client Access\Emulator\Private\" &
"SHRDSP96A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' PC
ElseIf Dir("C:\Documents and Settings\trans1\My Documents\IBM\Client
Access\Emulator\private\SHRDSP98A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Documents and Settings\trans1\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP98A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\trans2\My Documents\IBM\Client
Access\Emulator\private\SHRDSP99A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Documents and Settings\trans2\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP99A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\spare\My Documents\IBM\Client
Access\Emulator\private\") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe
" & _
Q & "C:\Documents and Settings\spare\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP97A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

Else
MsgBox "Local Display Not Found in VBCode"

End If
End Sub

Nov 12 '05 #1
3 2566
DFS
Joe,

Use FileLen(file path and name) <> 0


"Joe Costa" <jo******@nospam.com> wrote in message
news:10*************@corp.supernews.com...
I have written the following code to search for the right file depending on the startup file for "Client Access". The menu database that I made will
load the correct config file specific for each "Thin Client". The problem
is that we also use PC's to run the "Client Access" program and under the
following script it will create a match and load the wrong WS file.

I read that you should not use the DIR function but that's that only way I
thought to search for the file name. The problem is that on every computer there is a directory called ("C:\Program Files\IBM\Client
Access\Emulator\Private\") So I cant just search for the directory. The
thin clients are specific in location and I cant just have "C:\Program
Files\IBM\Client Access\Emulator\Private\" or else it will find it and then I get a VB crash according to the runtime running on the Thin Client.

I have tried the DIR without the WS file however this is when I get the VB
runtime errors on the Thin Clients.

Is there an easier way to search for the file? I don't want the user to
have any choice, I want the script to do it for them. If the computer *.WS file isn't found I want the error to display.

This is just the tip of the iceberg. I have 30 computers to add to the code with another 30 printers.

You can reply here or through email at jo******@nospam.com change to
core.com.

Thanks in advance...Everyone here has made me a better Access user! I
appreciate any and ALL help...

Private Sub Shrdsp96_Click()
Dim strCmdLine As String
Const Q = """"

' Thin Client
If Dir("C:\Documents and Settings\property\My Documents\IBM\Client
Access\Emulator\private\SHRDSP68A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Documents and Settings\property\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP68A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\medical\My Documents\IBM\Client
Access\Emulator\private\SHRDSP69A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Documents and Settings\medical\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP69A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' PC
ElseIf Dir("C:\Program Files\IBM\Client
Access\Emulator\Private\shrdsp96a.ws") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Program Files\IBM\Client Access\Emulator\Private\" &
"SHRDSP96A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' PC
ElseIf Dir("C:\Documents and Settings\trans1\My Documents\IBM\Client
Access\Emulator\private\SHRDSP98A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Documents and Settings\trans1\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP98A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\trans2\My Documents\IBM\Client
Access\Emulator\private\SHRDSP99A.WS") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Documents and Settings\trans2\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP99A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

' Thin Client
ElseIf Dir("C:\Documents and Settings\spare\My Documents\IBM\Client
Access\Emulator\private\") <> "" Then
strCmdLine = "C:\Program Files\IBM\Client Access\Emulator\" & "pcsws.exe " & _
Q & "C:\Documents and Settings\spare\My Documents\IBM\Client
Access\Emulator\private\" & _
"SHRDSP97A.WS" & Q
Call Shell(strCmdLine, vbNormalFocus)

Else
MsgBox "Local Display Not Found in VBCode"

End If
End Sub

Nov 12 '05 #2

I tried both ways and found that my error was something else. The below
works great if I only have 1 IF Dir statement. However I need to search
the other 2 directories as well.

When the code runs it will go to Exit_Search without searching thew other
2 directories. How can I add an OR statement. I tried the elseif
statement but it doesn't fit in here..

'----------------
' Begin Code snipit
'----------------

IF Dir("C:\I386\") <> "" then goto Personal_Computer
IF Dir("\\ccsda\profiles$\") <> "" then goto Thin_Client
IF Dir("\\ccsdb\profiles$\") <> "" then goto Thin_Client

Goto Exit_Search

'----------------
' End code snipit
'----------------

In article <10*************@corp.supernews.com>, no****@nospam.com
says...
Joe,

Use FileLen(file path and name) <> 0

Nov 12 '05 #3
Joe Costa <jo******@spamcore.com> wrote in message news:<MP***********************@news-radius.core.com>...
I tried both ways and found that my error was something else. The below
works great if I only have 1 IF Dir statement. However I need to search
the other 2 directories as well.

When the code runs it will go to Exit_Search without searching thew other
2 directories. How can I add an OR statement. I tried the elseif
statement but it doesn't fit in here..

'----------------
' Begin Code snipit
'----------------

IF Dir("C:\I386\") <> "" then goto Personal_Computer
IF Dir("\\ccsda\profiles$\") <> "" then goto Thin_Client
IF Dir("\\ccsdb\profiles$\") <> "" then goto Thin_Client

Goto Exit_Search

'----------------
' End code snipit
'----------------

How about...

IF Dir("C:\I386\") <> "" then goto Personal_Computer
ELSEIF Dir("\\ccsda\profiles$\") <> "" then goto Thin_Client
ELSEIF Dir("\\ccsdb\profiles$\") <> "" then goto Thin_Client
END IF
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by teoryn | last post: by
3 posts views Thread by my-wings | last post: by
22 posts views Thread by mrkafk | last post: by
1 post views Thread by khore | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.