PDA

Click to See Complete Forum and Search --> : Problem with Sub-Routine


Rick B
Feb 13th, 2000, 04:00 AM
Can anyone tell me why the first Else doesn't ever seem to be true. My program keeps ignoring it.

Select Case Data1.Recordset.EditMode

Case dbEditNone ' No edit taking place, just handle Navigation

If (lngTotal_Records > 2) Then
If (Data1.Recordset.BOF) Or (Data1.Recordset.AbsolutePosition = 0) Then
NavigateButtons ("0011110101")
ElseIf (Data1.Recordset.EOF) Or (Data1.Recordset.AbsolutePosition = _
lngTotal_Records) - 1 Then
NavigateButtons ("1100110101")
Else ' THIS ELSE WILL NOT RUN FOR SOME REASON
NavigateButtons ("1111110101")
End If

ElseIf (lngTotal_Records > 0) Then
NavigateButtons ("0000110101")
Else
NavigateButtons ("0000100001")
End If
If (Not IsMissing(blnLockEm)) Then
LockTheControls (blnLockEm)
End If

Case dbEditInProgress ' We are editing the current record
Call LockTheControls(False)
TxtBx1(1).SetFocus
NavigateButtons ("0000001010")

Case dbEditAdd ' We are adding a record
Call LockTheControls(False)
TxtBx1(1).SetFocus
NavigateButtons ("0000001010")
End Select

MartinLiss
Feb 13th, 2000, 04:34 AM
Put a breakpoint on the first If and then step through the code (F8). You should then be able to look at the variables involved and determine why it's not working.

------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"

Rick B
Feb 13th, 2000, 05:29 AM
Yeah, I've done that. I've also reduced the select case down to each of the 'IF' statements and followed it through ike that and everything seem to be fine.

My program seems to only check for BOF and EOF. There is something fundemently wrong with the nested if statements but I'll be damned if I can see it....

Thanks

pardede
Feb 13th, 2000, 06:07 AM
maybe your mistake is in this line:

ElseIf (Data1.Recordset.EOF) Or (Data1.Recordset.AbsolutePosition = _
lngTotal_Records) - 1 Then

which should be:

ElseIf (Data1.Recordset.EOF) Or (Data1.Recordset.AbsolutePosition = _
lngTotal_Records - 1) Then

the "- 1" should be within the parenthesis?

(please do tell me if this is it..)

Rick B
Feb 13th, 2000, 07:08 AM
Jesus.....Y'know when ya can't see the wood for the trees.....

Thanks Pardede, you wer bang on correct...

Well played and you just saved my Cat from gettin it :)