cravincreeks
Technical User
Hello all.
I'm trying to test some code that's executed by an Access form, but am encountering what seems to be some inconsistent behavior. This form is used for data entry and has many tabs on it. The first tab has THE four required fields. When they change a combo box on another tab, it triggers the following event procedure. But I want to make sure that the record is saved in the table before the event procedure is executed ... hence the first line of code
If I create a new record via the form, complete the four required fields and then change the value in the cboToOwner combo box, the code executes OK. If I put a break point on the first line (If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord) and do the same as before, then the form is dirty and the DoCmd executes. So if the break point making the form dirty? That's all that really make sense to me, but I want to make sure I understand what's happening.
Also, the error that the RunCommand acCmdSaveRecord is throwing:
"The command or action 'Save Record' is not available now". Any idea why?
Thanks
Alex
I'm trying to test some code that's executed by an Access form, but am encountering what seems to be some inconsistent behavior. This form is used for data entry and has many tabs on it. The first tab has THE four required fields. When they change a combo box on another tab, it triggers the following event procedure. But I want to make sure that the record is saved in the table before the event procedure is executed ... hence the first line of code
Code:
Private Sub cboToOwner_Change()
If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord 'save the record so the source data can be found in the table
Dim sFileName As String
Me.filenum.SetFocus
sFileName = filenum.Text
Me.cboToOwner.SetFocus
Call CopyContactInfo(GetTableName(cboToOwner), "tOwnerAddress", filenum, cboToOwner.Text)
Me.Refresh
End Sub
If I create a new record via the form, complete the four required fields and then change the value in the cboToOwner combo box, the code executes OK. If I put a break point on the first line (If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord) and do the same as before, then the form is dirty and the DoCmd executes. So if the break point making the form dirty? That's all that really make sense to me, but I want to make sure I understand what's happening.
Also, the error that the RunCommand acCmdSaveRecord is throwing:
"The command or action 'Save Record' is not available now". Any idea why?
Thanks
Alex