Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cycling through recordsets

I set up to buttons: previous and next. I want to be able to cycle through the records in the table using the buttons rather than the data control. I know about movefirst, next, previous and all of those. My question is how do I cycle through the record sets and when it gets to the last record the button is diabled. Thats the easy part. The hard part, i think, is not getting the blank record to come up. So how do I cycle through the record using the buttons to where when it reaches the last record with information, not the blank one, the button is disabled.


Thanks

Josh


Comments

  • I'm only guessing, since I don't mess with recordsets, but can't you make it look ahead to the next record? If the next record is blank, disable the button, if it's not, then you can store the next record in a variable, so when they want the next record, you can load from there instead of looking it up. Faster, I would think.


  • : I set up to buttons: previous and next. I want to be able to cycle through the records in the table using the buttons rather than the data control. I know about movefirst, next, previous and all of those. My question is how do I cycle through the record sets and when it gets to the last record the button is diabled. Thats the easy part. The hard part, i think, is not getting the blank record to come up. So how do I cycle through the record using the buttons to where when it reaches the last record with information, not the blank one, the button is disabled.


    : Thanks

    : Josh


    Maybe this code will give you ideas:


    Sub Data1_Reposition ()

    'First_MCW%

    zWeek = uWeek

    zDate = u_Date

    zToe = uToe

    zToe.BackColor = uToe.BackColor

    zP1 = uP1

    zP1.BackColor = uP1.BackColor

    zP1.ForeColor = uP1.ForeColor

    zP2 = uP2

    zP2.BackColor = uP2.BackColor

    zP2.ForeColor = uP2.ForeColor

    zP3 = uP3

    zP3.BackColor = uP3.BackColor

    zP3.ForeColor = uP3.ForeColor

    zP4 = uP4

    zP4.BackColor = uP4.BackColor

    zP4.ForeColor = uP4.ForeColor

    zP5 = uP5

    zP5.BackColor = uP5.BackColor

    zP5.ForeColor = uP5.ForeColor

    zP6 = uP6

    zP6.BackColor = uP6.BackColor

    zP6.ForeColor = uP6.ForeColor

    If Keep_Record_Count% = First_MCW% Then

    dc1.Caption = BLANK$

    tWeek.BackColor = GRAY

    tDate.BackColor = GRAY

    tTOE.BackColor = GRAY

    tP1.BackColor = GRAY

    tP1.ForeColor = BLACK

    tP2.BackColor = GRAY

    tP2.ForeColor = BLACK

    tP3.BackColor = GRAY

    tP3.ForeColor = BLACK

    tP4.BackColor = GRAY

    tP4.ForeColor = BLACK

    tP5.BackColor = GRAY

    tP5.ForeColor = BLACK

    tP6.BackColor = GRAY

    tP6.ForeColor = BLACK

    uWeek.BackColor = GRAY

    u_Date.BackColor = GRAY

    uToe.BackColor = GRAY

    uP1.BackColor = GRAY

    uP1.ForeColor = BLACK

    uP2.BackColor = GRAY

    uP2.ForeColor = BLACK

    uP3.BackColor = GRAY

    uP3.ForeColor = BLACK

    uP4.BackColor = GRAY

    uP4.ForeColor = BLACK

    uP5.BackColor = GRAY

    uP5.ForeColor = BLACK

    uP6.BackColor = GRAY

    uP6.ForeColor = BLACK

    uWeek = tWeek

    u_Date = tDate

    uToe = tTOE

    uP1 = tP1

    uP2 = tP2

    uP3 = tP3

    uP4 = tP4

    uP5 = tP5

    uP6 = tP6

    MsgBox "Records beyond " & First_MCW% & " are future events.", 0, "End of Records with Values"


    End If

    Keep_Record_Count% = Keep_Record_Count% + 1


    'Set dc1 = Data1

    If Not dc1.Recordset.EOF Then

    If Not IsNull(dc1.Recordset!ID) Then

    dc1.Caption = BLANK$

    tWeek.BackColor = GRAY

    tDate.BackColor = GRAY

    tTOE.BackColor = GRAY

    tP1.BackColor = GRAY

    tP1.ForeColor = BLACK

    tP2.BackColor = GRAY

    tP2.ForeColor = BLACK

    tP3.BackColor = GRAY

    tP3.ForeColor = BLACK

    tP4.BackColor = GRAY

    tP4.ForeColor = BLACK

    tP5.BackColor = GRAY

    tP5.ForeColor = BLACK

    tP6.BackColor = GRAY

    tP6.ForeColor = BLACK

    uWeek.BackColor = GRAY

    u_Date.BackColor = GRAY

    uToe.BackColor = GRAY

    uP1.BackColor = GRAY

    uP1.ForeColor = BLACK

    uP2.BackColor = GRAY

    uP2.ForeColor = BLACK

    uP3.BackColor = GRAY

    uP3.ForeColor = BLACK

    uP4.BackColor = GRAY

    uP4.ForeColor = BLACK

    uP5.BackColor = GRAY

    uP5.ForeColor = BLACK

    uP6.BackColor = GRAY

    uP6.ForeColor = BLACK

    uWeek = tWeek

    u_Date = tDate

    uToe = tTOE

    uP1 = tP1

    uP2 = tP2

    uP3 = tP3

    uP4 = tP4

    uP5 = tP5

    uP6 = tP6

    Call Get_Color

    '====USE TO COUNT INTERRUPTS

    'Change lbInterrupt.Visible = true on prop sheet

    ' If zToe = tTOE Then

    ' If tTOE = "1" Then

    ' Count_the_Interrupts% = Count_the_Interrupts% + 1

    ' lbInterrupt = Format$(Count_the_Interrupts%)

    ' End If

    ' End If

    '====USE TO COUNT INTERRUPTS

    Else

    dc1.Caption = BLANK$

    End If

    Else

    Select Case Flg_EOF%

    Case True

    dc1.Caption = dc1_finish_Cap$

    Flg_EOF% = False

    Exit Sub

    Case False

    dc1.Caption = dc1_norcds_Cap$

    End Select

    End If


    End Sub







  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    __ // http://forcoder.org // free video tutorials and ebooks about // Visual Basic .NET C Go MATLAB PHP R JavaScript Objective-C Perl Scratch Visual Basic Delphi PL/SQL C# Ruby Python Swift Assembly C++ Java Scheme Lua Julia ABAP Hack Apex Kotlin F# Lisp Alice Rust Awk LabVIEW ML Prolog Bash Clojure Crystal Ada FoxPro Dart SAS Logo VBScript D COBOL Transact-SQL Erlang Fortran Scala // ___________

Sign In or Register to comment.