G
Guest
HERE IS WHAT I HAVE
Form: Job Work Orders Form (it’s bound to Job Work Order Query)
Query: Job Work Orders Query
Tables: Customers Table
Projects Table
Customer Contacts Table
Project Managers Table
Insurance Companies Table
Insurance Contacts Table
Job Superintendents Table
Job Work Order Table
On the Job Work Orders Form, each of the following fields are Combo Boxes:
Customer
Project
Customer Contact
Project Manager
Job Superintendent
Insurance Company
Insurance Contact
Each of these combo boxes has an On Not In List Event Procedure, and the
code is to add the data to the table. Here is one example:
Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Customer_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("You are adding " & Chr(34) & NewData & _
Chr(34) & " as a new customer." & vbCrLf & _
"Are you sure this is not a typo and you want do this?" _
, vbQuestion + vbYesNo, "Customers")
If intAnswer = vbYes Then
strSQL = "INSERT INTO [Customers Table]([CU_Customer]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded
Else
MsgBox "Please select an existing customer from the list then." _
, vbInformation, "Customers"
Response = acDataErrContinue
End If
Customer_NotInList_Exit:
Exit Sub
Customer_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Customer_NotInList_Exit
End Sub
The rest are only different based on the name of the fields, tables, etc.
In addition, the Customer Contact, Project Manager, Job Superintendent Combo
Boxes are all synchronized to the Customer Combo Box, and the Insurance
Contact Combo Box is synchronized to the Insurance Company Combo Box. To do
this, they each have an SQL Statement in the Row Source. Here is the example
for Customer Contacts:
SELECT [Customer Contacts Table].CC_CustomerContactID, [Customer Contacts
Table].[CC_Contact Person], [Customer Contacts Table].CC_Company FROM
[Customer Contacts Table] WHERE ((([Customer Contacts
Table].CC_Company)=Forms![Job Work Orders Form]!Customer)) ORDER BY [Customer
Contacts Table].[CC_Contact Person];
The Customer Combo Box has the After Update Event Procedure, and the code is
to requery the three other synchronized combo boxes.
If the Not In List code is not in, the requery works in each of the
synchronized boxes. And, the Not In List code works for each of the fields
as long as the requery isn’t on. But when both codes are present I get the
following error when I select the Customer or the Insurance Company:
The expression After Update you entered as the event property setting
produced the following error: Ambiguous name detected: Project_Name_NotInList.
*The expression may have been a result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
And, the other synchronized combo boxes are blank… HOW DO I FIX THIS?
Form: Job Work Orders Form (it’s bound to Job Work Order Query)
Query: Job Work Orders Query
Tables: Customers Table
Projects Table
Customer Contacts Table
Project Managers Table
Insurance Companies Table
Insurance Contacts Table
Job Superintendents Table
Job Work Order Table
On the Job Work Orders Form, each of the following fields are Combo Boxes:
Customer
Project
Customer Contact
Project Manager
Job Superintendent
Insurance Company
Insurance Contact
Each of these combo boxes has an On Not In List Event Procedure, and the
code is to add the data to the table. Here is one example:
Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Customer_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("You are adding " & Chr(34) & NewData & _
Chr(34) & " as a new customer." & vbCrLf & _
"Are you sure this is not a typo and you want do this?" _
, vbQuestion + vbYesNo, "Customers")
If intAnswer = vbYes Then
strSQL = "INSERT INTO [Customers Table]([CU_Customer]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded
Else
MsgBox "Please select an existing customer from the list then." _
, vbInformation, "Customers"
Response = acDataErrContinue
End If
Customer_NotInList_Exit:
Exit Sub
Customer_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Customer_NotInList_Exit
End Sub
The rest are only different based on the name of the fields, tables, etc.
In addition, the Customer Contact, Project Manager, Job Superintendent Combo
Boxes are all synchronized to the Customer Combo Box, and the Insurance
Contact Combo Box is synchronized to the Insurance Company Combo Box. To do
this, they each have an SQL Statement in the Row Source. Here is the example
for Customer Contacts:
SELECT [Customer Contacts Table].CC_CustomerContactID, [Customer Contacts
Table].[CC_Contact Person], [Customer Contacts Table].CC_Company FROM
[Customer Contacts Table] WHERE ((([Customer Contacts
Table].CC_Company)=Forms![Job Work Orders Form]!Customer)) ORDER BY [Customer
Contacts Table].[CC_Contact Person];
The Customer Combo Box has the After Update Event Procedure, and the code is
to requery the three other synchronized combo boxes.
If the Not In List code is not in, the requery works in each of the
synchronized boxes. And, the Not In List code works for each of the fields
as long as the requery isn’t on. But when both codes are present I get the
following error when I select the Customer or the Insurance Company:
The expression After Update you entered as the event property setting
produced the following error: Ambiguous name detected: Project_Name_NotInList.
*The expression may have been a result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
And, the other synchronized combo boxes are blank… HOW DO I FIX THIS?