Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Form shows #Name and #Error on last line ACCESS 2010

I have an inherited form that I am updating.  The query behind the form is changed in code, but is a simple select.  However, on the form, when the records display, the very last record has #Name in the first field and Error in a few others.  It returns the filtered records, but always with this last line and not sure how to get rid of it.  Attached is a screen shot and below is the code.

Private Sub cboProgram_AfterUpdate()
On Error GoTo ErrorHandler
    Dim strProgram As String
    Dim strSelect As String

strSelect = "SELECT [FirstName] & ' ' & [LastName] AS Fullname, tblPersonProgramHistory.* " & _
                "FROM tblPerson INNER JOIN tblPersonProgramHistory ON tblPerson.PersonID = tblPersonProgramHistory.PersonID "


    If Not IsNull(Me.cboProgram) And Me.cboProgram <> "<All>" Then
            strProgram = Me.cboProgram.Column(0)
            strSelect = strSelect & " WHERE Program = '" & strProgram & "' "
            Me.RecordSource = strSelect
            Me.Requery
    ElseIf Me.cboProgram = "<All>" Then
            Me.RecordSource = strSelect
            Me.Requery
    End If


Exit_ErrorHandler:
    Exit Sub
ErrorHandler:
    MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description
    Resume Exit_ErrorHandler
End Sub
ProgramHistoryError.png
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

It worked, thank you.  I just have never had this problem before.