Some help explaining a snippet of code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • martin DH
    New Member
    • Feb 2007
    • 114

    #1

    Some help explaining a snippet of code?

    Could anyone help explain the following snippet of code? I'm not quite sure how it works. Thanks!

    [CODE=vb]Public Counter As Integer
    Private Sub Form_Load()
    If Me.CurrentRecor d > 0 Then
    DoCmd.GoToRecor d acActiveDataObj ect, "", acLast
    Counter = Me.CurrentRecor d
    DoCmd.GoToRecor d acActiveDataObj ect, "", acFirst
    Else
    MsgBox "There are no new issues.", vbOKOnly, "First Issues"
    DoCmd.Close acForm, "frmEditReport" , acSaveNo
    Exit Sub
    End If
    End Sub[/CODE]
    Software: Access 2003
    Form: frmEditReport
    Form's Record Source: qryEditReport
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by martin DH
    Could anyone help explain the following snippet of code? I'm not quite sure how it works. Thanks!

    [CODE=vb]Public Counter As Integer
    Private Sub Form_Load()
    If Me.CurrentRecor d > 0 Then
    DoCmd.GoToRecor d acActiveDataObj ect, "", acLast
    Counter = Me.CurrentRecor d
    DoCmd.GoToRecor d acActiveDataObj ect, "", acFirst
    Else
    MsgBox "There are no new issues.", vbOKOnly, "First Issues"
    DoCmd.Close acForm, "frmEditReport" , acSaveNo
    Exit Sub
    End If
    End Sub[/CODE]
    Software: Access 2003
    Form: frmEditReport
    Form's Record Source: qryEditReport
    It appears as though this code will:
    1. Calculate the Total Number of Records in the Record Source of the displayed Form (by navigating to the Last Record) and placing its value in the Public Variable Counter (Lines 4 and 5). This will only be done if there is a Current Record.
    2. Reposition the Record Pointer to the first Record (Line 6).
    3. If there is no Current Record, display a Message Box and close frmEditReport (Lines 8 and 9).

    Comment

    Working...