Problem with code - Help

L

Les

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub
 
J

Joel

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window
 
J

Joel

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.
 
L

Les

Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
 
J

Joel

You better signgle step through the old module and new module to see the
difference in the two modules.

Left click on first instruction in code. then press F8 to step through
code. See which item(s) is false in old code. Compare with new code.

I don't see any thing in the code you posted that is dependant on a NEW MODULE
 
L

Les

That is the problem, if i step through with F8 it works but with F5 and
running it goes to "Problem:"

I am really puzzled....
 
J

Joel

Put a break point on Problem using F9. Then add variabgbles to watch window
(right click on variable) like blnIhKtl to find out which is not set
corrrectly. I suspect you may have problems with your IfSheetExistsTestIH
macro.
 
L

Les

Thanks, will try that...
--
Les


Joel said:
Put a break point on Problem using F9. Then add variabgbles to watch window
(right click on variable) like blnIhKtl to find out which is not set
corrrectly. I suspect you may have problems with your IfSheetExistsTestIH
macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top