Dim strSQL As String, strWhere As String
strSQL = Left(Me.txt2.RowSource, Len(Me.txt2.RowSource) - 1)
If IsNull(Me.txt1) = False Then
strWhere = " Student.StudentNumber = '" & Me.txt1 & "' AND"
End If
If IsNull(Me.txt3) = False Then
strWhere = strWhere & " Student.PostCode = '" & Me.txt3 & "'"
End If
If IsNull(strWhere) = False
strWhere = " WHERE" & strWhere
End If
If Right(strWhere, 4) = " AND" Then
strWhere = Left(strWhere, Len(strWhere) - 4)
End If
strWhere = strWhere & ";"
strSQL = strSQL & strWhere
txt2.RowSource = strSQL