0 Replies - 1963 Views - Last Post: 03 May 2013 - 07:49 AM Rate Topic: -----

#1 C.Andrews   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 169
  • Joined: 18-October 12

Let's reinvent the wheel...as a square

Posted 03 May 2013 - 07:49 AM

So, I've inherited a program that was written for my company by a professional software solutions provider several years ago to provide a touch-screen friendly user interface for selecting birds in a poultry breeding operation. The program is written in MS Access VBA, and let me tell you, it's an unholy catastrophe of non-standard programming conventions, vague variable names, repetitive code, endless unnecessary database IO, etc.

Every time I have to make changes in it, I wind up with a splitting headache from trying to figure out what it's written the way it is, but this week, I found the crown jewel of this entire dysfunctional train wreck. There's a part of the process where if a bird has a defect, the user pushes a button which brings up a smaller form with ten command buttons with numbers 0-9.

The layout is completely nonstandard:
Attached Image

...but the worst part is, the numbers assigned to each button at design time are NOT the values returned by pushing the buttons... instead, the value of each button changes when the form is loaded so that when you click a defect button, the most common value for that defect comes up right where you clicked to get the "score" form.

Here's how it's done:

Private Sub Form_Load()
' This procedure runs when the form loads.
    Dim rst As DAO.Recordset
    Dim intOpt As Integer
    Me.Caption = "Defect Score - " & Me.OpenArgs
    Set rst = Me.Recordset
    For intOpt = 0 To 9
        With Me.Controls("opt" & intOpt)
            If IsNull(rst("D" & intOpt)) Then
                .Visible = False
               .Caption = rst("D" & intOpt)
               .OptionValue = rst("D" & intOpt)
            End If
        End With
    Next intOpt

End Sub

What is this load event doing, you ask? Why, it's simple: we're looking in a datatable which contains columns D0-D9. In those columns is a number, also 1-9, which this sub uses to determine what value each command button in the form takes on. For example, in the images below, that same form is displayed after clicking two different defect buttons. We didn't MOVE the buttons around, we just changed the values of the buttons put there at design time to get the demented layout we're going for.
Attached Image

Attached Image
I can't imagine how anyone could have paid money for this application, or how a profit seeking entity could have possibly thought it was ok to design an interface like this. Makes me tear my hair out every time someone makes me work on this.

Is This A Good Question/Topic? 1
  • +

Page 1 of 1