OK, I want to say that I understand that this is a dB that you inherited.... but there are a lot of things that need/should be fixed (IMHO). So this is in no way directed at you.
I converted the linked tables to local tables. That took care of the start up errors.
There is a control on the main form for "Project Num", but there is not a field in any table for "Project Num"!
I don't like using compound primary keys - every table has an autonumber field that I use as the PK field. (See Microsoft Access Tables: Primary Key Tips and Techniques)
As minty said, there are lots of things in the code that could be cleaned up. I would also convert the macros to VBA code - I never use macros.
The first thing I would do is remove ALL SPACES in all object names.
In the module "Rate Functions", in the Function AddRates, you have this snippet of code:
Code:
<snip>
If (
(rT120![Supplier Num] = Null) _
Or (rT120![ContractArea] = Null) _
Or (rT120![Start Date] = Null) _
Or (rT120![End Date] = Null) _
Or (rT120![Rate No] = Null) _
Or (rT120![Rate] = Null) _
Or (rT120![UOM] = Null) _
)
Then
iCntNull = iCntNull + 1
GoTo LabelNextRecord
End If
<snip>
You CANNOT test if a control/field = NULL! The If() test will ALWAYS be FALSE because nothing is equal to null, not even null.
If A = NULL --> the result is False
If Null = Null --> the result is False
If you want to test if a control/field is NULL, you should use the IsNull function
Code:
If IsNull(rT120![Supplier Num]) Then
Bla-bla
Else
Yada-yada
End If
Or check the length of the value
Code:
If Len(Trim(rT120![Supplier Num] & "")) Then
Bla-bla
Else
Yada-yada
End If
I changed the record source for the form "F005_List_Work_Orders_Selected" and modified the code to open the form
Code:
' Prepare SQL query
If varWhere = "" Then
varWhere = "[Work Order ID] > 0"
End If
' Debug.Print varWhere
'To see the sql on the screen you need to make the txtSearchQuery box Visible = Yes and then rerun.
' Me.[txtSearchQuery] = "SELECT * FROM T010_Work_Order WHERE (" & varWhere & ") ORDER BY [Proposed Date];"
' Me.Refresh
Call ResetWorkOrderID
DoCmd.OpenForm "F005_List_Work_Orders_Selected", , , varWhere
EDIT: Tables T100_Regions, T105_Areas and T110_Depots have a field named "Current". "Current" is a reserved word in Access.
(JET reserved (kb248738);SQL Server reserved;ODBC (kb125948);ANSI-92 Reserved (kb287417))
I'm attaching the dB I modified. Would you add data to the tables and put in 5 - 10 work order records for testing?