Ok...I've been working on this and cannot quite get it to work.
The user can add a project by clicking the button.
There is some validation of control in the before update...works good.
The user can then select the 'Open Contract' button.
There is some validation of control in the before update...works good.
Two problems:
1. When you click the close button in F_Contract, you have to click it twice. I see why this is happening in my code but, I don't know how to fix it. I simply want to click the button once and close. How do I fix this code and still get the validation of control to work?
Code:
Private Sub ButtonClose_F_Contract_Click() On Error Resume Next If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord 'This trys to save but the BeforeUpdate event fires which has the Public Function in it. Else DoCmd.Close End IfEnd Sub
2. When the F_Contract is closed, I cannot get the combo box, cboContract to land on the TEMP contract number that was generated in F_Contract.
If I choose …..listcount -1, it gives me the next to last in the list. Which is expected. But if I choose ….listcount , (with no "- 1" at the end) then it gives me a blank. How do I correct this?
Code:
Dim LastRow As Integer LastRow = Forms!F_Project!SF_Contract!cboContract.ListCount ctlCombo.Value = Forms!F_Project!SF_Contract!cboContract.ItemData(LastRow)
See my attached sample database.
Thanks for any help.

The user can add a project by clicking the button.
There is some validation of control in the before update...works good.
The user can then select the 'Open Contract' button.
There is some validation of control in the before update...works good.
Two problems:
1. When you click the close button in F_Contract, you have to click it twice. I see why this is happening in my code but, I don't know how to fix it. I simply want to click the button once and close. How do I fix this code and still get the validation of control to work?
Code:
Private Sub ButtonClose_F_Contract_Click() On Error Resume Next If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord 'This trys to save but the BeforeUpdate event fires which has the Public Function in it. Else DoCmd.Close End IfEnd Sub
2. When the F_Contract is closed, I cannot get the combo box, cboContract to land on the TEMP contract number that was generated in F_Contract.
If I choose …..listcount -1, it gives me the next to last in the list. Which is expected. But if I choose ….listcount , (with no "- 1" at the end) then it gives me a blank. How do I correct this?
Code:
Dim LastRow As Integer LastRow = Forms!F_Project!SF_Contract!cboContract.ListCount ctlCombo.Value = Forms!F_Project!SF_Contract!cboContract.ItemData(LastRow)
See my attached sample database.
Thanks for any help.