Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help understanding coding referencing a table

Status
Not open for further replies.

EdAROC

Programmer
Aug 27, 2002
93
US
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 dbo_ORD_MACH_OPS.MACH_NO as Machine, dbo_ORD_MACH_OPS.ORDER_NO as Job, "
strSQL = strSQL & "dbo_ORD_MACH_OPS.SPEC_NO as Spec, dbo_ORD_MACH_OPS.ITEM_NO as Item, "
strSQL = strSQL & "dbo_ORD_MACH_OPS.FORM_NO as Form FROM dbo_ORD_MACH_OPS "
strSQL = strSQL & "INNER JOIN MACHINES ON dbo_ORD_MACH_OPS.MACH_NO = MACHINES.MACH_NO "
strSQL = strSQL & "WHERE (((dbo_ORD_MACH_OPS.ORDER_NO) = " & JNo & ") "
strSQL = strSQL & "And ((dbo_ORD_MACH_OPS.FORM_NO) = " & FNo & ") "
strSQL = strSQL & "And dbo_ORD_MACH_OPS.REPLACED_MACH_NO Is Null "
strSQL = strSQL & "And (MACHINES.SCHEDCARDS_FLG = 'Y')) "
strSQL = strSQL & "ORDER BY dbo_ORD_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
 
Looks like they can but I would first do a global search of the project looking for the string "MachineInfo" just to satisfy yourself that it isn't referenced elsewhere.

You could also rename the table and then run your system. It should raise an error anywhere that "MachineInfo" is referenced and doesn't exist.

It also appears that dbo_ORD_MACH_OPS is an SQL Server table and some past programmer wanted to make a copy of selected information from it in a local table. Possibly for performance reasons but it's anyone's guess what the real reasons were.
 
Thanks Golom.

You are correct about ORD_MACH_OPS (Order Machine Operations) being one of the ERP tables (SQL based). This utility prints Scheduling Cards - one for each manufacturing operation.

OK, my ignorance is showing, can't find anything in Access's Help, nor any of my 3 Access books...

How do I perform a global search of the project?
 
Go into the code for a form or module. Press "Ctrl F", select "Entire Project", enter "MachineInfo" in the text box (without the quotes) and click "Find Next".
 
Got it. Thanks for your help. Appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top