Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting a break point in a form's event proc makes the form 'dirty' ??

Status
Not open for further replies.

cravincreeks

Technical User
Jun 18, 2004
85
US
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

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
 
If you've put a breakpoint in to break out to debug mode acCmdSaveREcord is not available (the record has to be the active object for this to work) hence the error being thrown.

According to Access help, the Dirty property determines "whether the current record has been modified since it was last saved", whilst the Dirty event "occurs when the contents of a form or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control." So no, I doubt that the breakpoint is dirtying your form.

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top