Form....................... PK Value .................................................. ........Action
MainMenu ....-->................................................. ....................... click on button "All Customers"
AllCustomers --> (AllCustomersQ.CustomerDatabaseID = 10) --> .........click on button "Edit"
Lead ...........--> (tblCustomerDatabase.CustomerDatabaseID = 10) --> click on button "2.1 Identity"
Error in code!!!
Code:
Docmd.OpenForm "Form2", acNormal, , "[CustomerDatabaseID]=" [&CustomerDatabaseID], , acNormal
Should be
Code:
DoCmd.OpenForm "Form2", acNormal, , "[CustomerDatabaseID]=" & [CustomerDatabaseID], , acNormal
****** EDIT: the above error could be caused by the Convert Macro to Visual Basic wizard....... *******
Form2 --> (tblCustomerDatabase.CustomerDatabaseID = 10) --> ......... click on button "Intro Letter"
The code that runs when the button "Intro Letter" is clicked is
Code:
Private Sub Letterbtn_Click()
DoCmd.OpenForm "CompanyLetter", acNormal, , , acFormEdit, , Me!CustomerDatabaseID
End Sub
Note that Me!CustomerDatabaseID (which is 10) is in the "OpenArgs" parameter
CompanyLetter -->
has code in the Form Load event
Code:
Private Sub Form_Load()
If Me.NewRecord Then Me!CustomerDatabaseID = Me.OpenArgs
RunCommand acCmdSaveRecord
End Sub
Form "CompanyLetter" is bound to "tblCompanyDDIdentity". BUT there is only one record in the table........ tblCompanyDDIdentity.CustomerDatabaseID = 9
And there is nothing in the code to set the current record to tblCompanyDDIdentity.CustomerDatabaseID = 10! (if it exists)
So CustomerDatabaseID = 10 was passed to the form "CompanyLetter" using "OpenArgs" parameter, - no code tries to set the current record to the "OpenArgs" parameter value.
Because there is only one record (#9), that is the record displayed. No filter is set.
So in the "CompanyLetter" Load event, there needs to be a check to see if there is a CustomerDatabaseID FK value in the table that matches the CustomerDatabaseID PK value.
If not, then add a new record else move to that record.
In the form "AllCustomers", the code for the button "Command103" (Show All) is wrong
Code:
Private Sub Command103_Click()
Me.Filter = FilterUK
Me.Filter = ""
Me.Requery
End Sub
I would try
Code:
Private Sub Command103_Click()
Me.Filter = ""
Me.FilterOn = False
End Sub
to remove the filter and show all records.