All,
I have borrowed this code from other messages on this forum, and it works, sort of.
Me.TrgCode = DMax("val(TrgCode)", "qryTrainingsForm", [ProgramCode] = Forms!frmTrainings!ProgramCode) + 1
What I need to do is tack a number onto a text value into a field that is later used to uniquely identify (to the average user--yes, there is actually a different PK field) a training course. The field consists of a Program Code and the number (chronological) of the course (e.g. AQ125 is the 125th course the air quality program has offered). I'd like this value to automatically increment by one for each individual program when users are entering data.
When I run the code, it just puts a number in the field and ignores the program code (in my example, "AQ")
Part of the problem might be that different users enter data for different programs, and I had the form's query set to a parameter (enter your program code), but when I had it set up that way, I get an automation error.
I need the code to somehow be able to recognize (or at least ask for) the program code (that is already entered into another field on the form) and then add the new number to it.
Any help would be greatly appreciated.
I have borrowed this code from other messages on this forum, and it works, sort of.
Me.TrgCode = DMax("val(TrgCode)", "qryTrainingsForm", [ProgramCode] = Forms!frmTrainings!ProgramCode) + 1
What I need to do is tack a number onto a text value into a field that is later used to uniquely identify (to the average user--yes, there is actually a different PK field) a training course. The field consists of a Program Code and the number (chronological) of the course (e.g. AQ125 is the 125th course the air quality program has offered). I'd like this value to automatically increment by one for each individual program when users are entering data.
When I run the code, it just puts a number in the field and ignores the program code (in my example, "AQ")
Part of the problem might be that different users enter data for different programs, and I had the form's query set to a parameter (enter your program code), but when I had it set up that way, I get an automation error.
I need the code to somehow be able to recognize (or at least ask for) the program code (that is already entered into another field on the form) and then add the new number to it.
Any help would be greatly appreciated.