I have a roster called tblroster with PK as SSN. I have another 2 tables that work with roster called tblPositionNumber and jnctblPositionRoster. Basically, I import an excel doc that updates a code on tblroster. I have a notes field on tblPositionNumber that needs to be updated when this code changes.
I have an afterupdate event set up like this (the codes field name is TCode):
This triggers if the code doesn't match the old code:
if [TCode]<>[old].[TCode]
SetLocalVar
Name: PositionID
Expression = Dlookup("[PositionID]","[jnctblPositionRoster]","[jnctblPositionRoster].[RosterID]=[tblRoster].[SSN]")
Look Up A Record In tblPositionNumber
Where Condition = [jnctblPositionNumber]=PositionID
Edit Record
SetField
ok so the set fields don't matter. The thing is that all of this works when done manually. I update the TCode on tblRoster, it looks up the persons positionID, finds them on the junction table and sets the field that I want properly however, when done with a query as part of the import/update function I've created in vba, it has trouble. It was just finding a random PositionNumber and trying to update that... at least as far as I could tell it was random. But every single person that had changes showed the same PositionNumber when they obviously aren't. It does find the right SSN but just the wrong position.
Anyone have any idea why it would do that? I would really prefer to do this in VBA but I can't seem to find a way to "monitor" tblRoster during update. It also does me no good to annotate every field based on the fact that TCode is present since TCode can come, go and change weekly so I would need some way of comparing old values to the new updated ones since it only matters if it's new or changed.
Hopefully this wasn't too long to turn people of to reading it and someone can give me an idea. Thanks for any assistance!!
I have an afterupdate event set up like this (the codes field name is TCode):
This triggers if the code doesn't match the old code:
if [TCode]<>[old].[TCode]
SetLocalVar
Name: PositionID
Expression = Dlookup("[PositionID]","[jnctblPositionRoster]","[jnctblPositionRoster].[RosterID]=[tblRoster].[SSN]")
Look Up A Record In tblPositionNumber
Where Condition = [jnctblPositionNumber]=PositionID
Edit Record
SetField
ok so the set fields don't matter. The thing is that all of this works when done manually. I update the TCode on tblRoster, it looks up the persons positionID, finds them on the junction table and sets the field that I want properly however, when done with a query as part of the import/update function I've created in vba, it has trouble. It was just finding a random PositionNumber and trying to update that... at least as far as I could tell it was random. But every single person that had changes showed the same PositionNumber when they obviously aren't. It does find the right SSN but just the wrong position.
Anyone have any idea why it would do that? I would really prefer to do this in VBA but I can't seem to find a way to "monitor" tblRoster during update. It also does me no good to annotate every field based on the fact that TCode is present since TCode can come, go and change weekly so I would need some way of comparing old values to the new updated ones since it only matters if it's new or changed.
Hopefully this wasn't too long to turn people of to reading it and someone can give me an idea. Thanks for any assistance!!