I have inherited a utility developed in Access. Most of the tables are links to our ERP database. There is a table created in this file name MachineInfo.
Looking at the queries, form and report I don't see MachineInfo records used - except in the function coding below, which builds records and another coding area (a form's cbPrint_click button) which deletes the records.
I'm anal about "clean code" (for myself and others who may inherit this) and want to remove unused stuff. I suspect this was used at one time and then a different solution made it obsolete.
Would someone review this and confirm what can be deleted?
I placed a ~ at the beginning of lines I believe can be deleted. A ? on the one I'm not sure about.
The MachinesNeeded string IS used elsewhere!!!
Public Function MachinesNeeded(JNo As Long, FNo As Integer) As String
Dim db As Database, rs As Recordset, strSQL As String, rsMachine As Recordset, bCombo As Boolean
~rsMachine As Recordset in Dim above~
'Creates table of Machines used
'Creates list of Machines used
? Set db = CurrentDb
~ Set rsMachine = db.OpenRecordset("MachineInfo")
'Return reference to current database.
strSQL = "SELECT db
RD_MACH_OPS.MACH_NO as Machine, db
RD_MACH_OPS.ORDER_NO as Job, "
strSQL = strSQL & "db
RD_MACH_OPS.SPEC_NO as Spec, db
RD_MACH_OPS.ITEM_NO as Item, "
strSQL = strSQL & "db
RD_MACH_OPS.FORM_NO as Form FROM db
RD_MACH_OPS "
strSQL = strSQL & "INNER JOIN MACHINES ON db
RD_MACH_OPS.MACH_NO = MACHINES.MACH_NO "
strSQL = strSQL & "WHERE (((db
RD_MACH_OPS.ORDER_NO) = " & JNo & ") "
strSQL = strSQL & "And ((db
RD_MACH_OPS.FORM_NO) = " & FNo & ") "
strSQL = strSQL & "And db
RD_MACH_OPS.REPLACED_MACH_NO Is Null "
strSQL = strSQL & "And (MACHINES.SCHEDCARDS_FLG = 'Y')) "
strSQL = strSQL & "ORDER BY db
RD_MACH_OPS.MACH_SEQ_NO"
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF
~ rsMachine.AddNew
~ rsMachine("Job") = rs("Job")
~ rsMachine("Spec") = rs("Spec")
~ rsMachine("Item") = rs("Item")
~ rsMachine("Machine") = rs("Machine")
~ rsMachine.Update
MachinesNeeded = MachinesNeeded & Trim(rs("Machine")) & "-"
rs.MoveNext
Loop
MachinesNeeded = Left(MachinesNeeded, Len(MachinesNeeded) - 1)
Else
MachinesNeeded = ""
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Looking at the queries, form and report I don't see MachineInfo records used - except in the function coding below, which builds records and another coding area (a form's cbPrint_click button) which deletes the records.
I'm anal about "clean code" (for myself and others who may inherit this) and want to remove unused stuff. I suspect this was used at one time and then a different solution made it obsolete.
Would someone review this and confirm what can be deleted?
I placed a ~ at the beginning of lines I believe can be deleted. A ? on the one I'm not sure about.
The MachinesNeeded string IS used elsewhere!!!
Public Function MachinesNeeded(JNo As Long, FNo As Integer) As String
Dim db As Database, rs As Recordset, strSQL As String, rsMachine As Recordset, bCombo As Boolean
~rsMachine As Recordset in Dim above~
'Creates table of Machines used
'Creates list of Machines used
? Set db = CurrentDb
~ Set rsMachine = db.OpenRecordset("MachineInfo")
'Return reference to current database.
strSQL = "SELECT db
strSQL = strSQL & "db
strSQL = strSQL & "db
strSQL = strSQL & "INNER JOIN MACHINES ON db
strSQL = strSQL & "WHERE (((db
strSQL = strSQL & "And ((db
strSQL = strSQL & "And db
strSQL = strSQL & "And (MACHINES.SCHEDCARDS_FLG = 'Y')) "
strSQL = strSQL & "ORDER BY db
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF
~ rsMachine.AddNew
~ rsMachine("Job") = rs("Job")
~ rsMachine("Spec") = rs("Spec")
~ rsMachine("Item") = rs("Item")
~ rsMachine("Machine") = rs("Machine")
~ rsMachine.Update
MachinesNeeded = MachinesNeeded & Trim(rs("Machine")) & "-"
rs.MoveNext
Loop
MachinesNeeded = Left(MachinesNeeded, Len(MachinesNeeded) - 1)
Else
MachinesNeeded = ""
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Function