Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

Our next failing test will be based around getting multiple fields changed and returned within the BeforeUpdate event.

'@TestMethod("Verify Changes")
Private Sub WhenTwoTextFieldsChangeBeforeAndAfterValuesAreReturned()
    Dim testFormAuditor As FormAuditor
    Dim testCollection As New Collection
    Dim TestTextChange As New AuditEventChange, TestComboChange As New AuditEventChange
    ChangeTestText "TextBeforeValue"
    ChangeTestCombo "ComboBeforeValue"
    Set testFormAuditor = New FormAuditor
    ChangeTestText "TextAfterValue"
    ChangeTestCombo "ComboAfterValue"
    Set testCollection = testFormAuditor.ListOfChanges
    Set TestTextChange = testCollection.Item(1).FieldChanges("TestText")
    Set TestComboChange = testCollection.Item(1).FieldChanges("TestCombo")
    Assert.IsTrue TestTextChange.OldValue = "TextBeforeValue" And TestTextChange.NewValue = "TextAfterValue" And TestComboChange.OldValue = "ComboBeforeValue" And TestComboChange.NewValue = "ComboAfterValue"
    End With
End Sub
Visual Basic

So this test will definitely fail because it tries to change a Combo control that isn’t on the form yet.

I will need to add a Combo control to the TestForm and bind it to the table, so I’ll have to add a new table field to bind it to.

So here is the new control on the test form bound to the new field:

Now I tried to run the refresh in RubberDuck, but it can’t compile yet because I wrote a new function to update the combo box values that isn’t there yet. Although strangely I am having problems with the whole DB, so I am going to close and reopen it and try again. Wow, still messed up. This time I’m looking a little more carefully and I am seeing RubberDuckVBA parse errors:

Looks like I am getting a compiler error that prevents me from doing my own Debug->Compile, however I do see the error there. It says a mismatched input “End With”. Which in my code I need to fix. After fixing that, I get another compiler error, this one a little more clear:

AuditEventChange should be AuditFieldChange. Even after doing that my test is still failing:

This one is broken because I am not looping through the fields to get the correct object set up and I had hard coded the Dictionary entry with the index “TestText”

More tomorrow!

Sign up For a Daily Email Adventure in Microsoft Access

Every business day (typically M-F), I'll send you an email with information about my ongoing journey as an advanced Access application developer. It will be loaded with my tips and musings.

    We won't send you spam. Unsubscribe at any time.