Results 1 to 5 of 5

Thread: Problem with Sub-Routine

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Yorkshire, UK
    Posts
    20

    Post

    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

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    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!"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Yorkshire, UK
    Posts
    20

    Post

    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

  4. #4
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232

    Post

    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..)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Yorkshire, UK
    Posts
    20

    Post

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width