
Originally Posted by
ssanfu
If I understand correctly, you have:
Code:
ShotNum ShotNumSuffix
5
5 A
5 B
5 C
6
6 A
6 B
6 C
6 D
7
7 A
8
8 A
8 B
----------------
You want to
Code:
6
6 A
Insert new record here
6 B
6 C
6 D
-----------------
which would results in:
Code:
6
6 A
6 B
6 C (was B)
6 D (was C)
6 E (was D)
Am I close?
On the nose! (In reality, the majority of records will be a single shotnumber with "" for the suffix, but that's immaterial.)
For the NEW record, how is the suffix determined? Some one says "I want this new record suffix to be 'B'"?
I call that an "insert mode" situation. I want the code to do the increments. (They can override after record is created if they wish.) So they'd click the 6A record to make it current and hit Ctrl-I. I trap for that in the Keydown event, like this:
Code:
If (KeyCode = vbKeyI And ((Shift And acCtrlMask) = acCtrlMask)) Then
strMode = "Insert"
curshotnumber = Nz(Me.ShotNumber)
curshotnumsuffix = IIf(IsNull(Me.ShotNumSuffix), "", Me.ShotNumSuffix)
strRecMarker = Me.Bookmark
DoCmd.GoToRecord , , acNewRec
Call rklMakeShotNumber(strMode, curshotnumber, curshotnumsuffix)
Me.ShotNumber = curshotnumber
Me.ShotNumSuffix = strShotNumSuffix
Me.Requery
Me.Bookmark = strRecMarker
DoCmd.GoToRecord , , acNext, 1
KeyCode = 0
End If
That mode variable signals the called routine to increment the suffix but not the number. I could post the called routine as well, but note: elegant I'm not.
And it's not sufficiently sophisticated to do what I want ie. exactly what you show, so what happens now is that the new record you've labeled 6b is actually 6e, and the original 6b through 6d remain unaltered. I'm not looking for code, btw, just a viable approach.
FWIW, for most data entry, they'd simply tab to a new record, OnCurrent fires and sends an "append mode" parameter to the called routine, which consequently increments only the ShotNumber. (BTW, I learned the hard way that the AcNewRecord parameter of DoCmd.GoToRecord also triggers the current event, so I trap out if On Current is fired while in "insert mode.")
Thanks for taking time, -Ron