Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to step through code

Status
Not open for further replies.

wokkie

Programmer
May 9, 2003
52
GB
When I put a breakpoint on a line of code and call the method containting the line it doesn't stop. The function continue to the end. I am able step through as normal on other databases and only have this problem with one. What have I done to cause this? Many thanks Ian
 
Public Function DeltaDays(StartDate As Date, EndDate As Date) As Integer
' code taken from
'Get the number of workdays between the given dates

Dim dbs As Database
Dim rstHolidays As dao.Recordset

Dim Idx As Long
Dim MyDate As Date
Dim NumDays As Long
Dim strCriteria As String
Dim NumSgn As String * 1

Set dbs = CurrentDb

Set rstHolidays = dbs.OpenRecordset("tblHolidays", dbOpenDynaset)

NumSgn = Chr(35)

'MyDate = Format(StartDate, "Short Date")
MyDate = FormatDateTime(StartDate, vbLongDate)


For Idx = CLng(StartDate) To CLng(EndDate)
Select Case (Weekday(MyDate))
Case Is = 1 'Sunday
'Do Nothing, it is NOT a Workday

Case Is = 7 'Saturday
'Do Nothing, it is NOT a Workday

Case Else 'Normal Workday
strCriteria = "[HoliDate] = " & NumSgn & MyDate & NumSgn
rstHolidays.FindFirst strCriteria
If (rstHolidays.NoMatch) Then
NumDays = NumDays + 1
Else
'Do Nothing, it is NOT a Workday
End If

End Select

MyDate = DateAdd("d", 1, MyDate)

Next Idx

DeltaDays = NumDays

MsgBox "fnDeltaDays" & DeltaDays


End Function
 
Sounds to me as if the line simply isn't reached.

Check your IF-Statements.
Best you put a breakpoint at your very first command line and step through your code from there. Then you'll find why your line is skipped.

Greetings,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Even when I put the break on the function name itself it doesn't stop. I have imported all the object into a new database and it now works :). It would be interesting to know what the matter was though. Cheers Ian
 
Were you calling the correct database in the name db. You are using the current one but if you are going to want to look for data in another I think you need to use its name.
 
After importing all the objects into a new database the "steping through" code thing worked fine. I made no changes to the code. The problem has be solved but I would like to know the reason. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top