Here's the code I used. I'm sure it's an error on my part. RainLover knows what he's doing so it surely has to be me.
Thanks
Private Sub txttblPO_AfterUpdate()
If (conHandleErrors) Then On Error GoTo ErrorHandler
' If we have some data
If Len(Me!txtlblPO) Then
' Find the highest number and increase it by ONE.
Me!tblPO = Nz(DMax("[PO]", "tblPO", "[PO] = '" & Me!txtlblPO & "'"), 0) + 1
Else
MsgBox "A String is Required", vbInformation, "Missing Information"
Screen.PreviousControl.SetFocus
Me.Undo
End If
' Added 03/02/2011 by Rainlover.
Me.txtConcatenated = Me.txttblPO & Me.txtlblPO
Me.Refresh
ExitProcedure:
Exit Sub
ErrorHandler:
DisplayError "txttlbPO_AfterUpdate", Me.Name
Resume ExitProcedure
End Sub
Private Sub Form_Error(ByRef intDataErr As Integer, ByRef intResponse As Integer)
' Designed by ChrisO.
' If in a multiuser environment it is quite possible for more that one
' machine to attempt to write the same value which will cause a Form Error.
' Handle the error and exit the Sub.
' Is it a duplicate index value error?
If intDataErr = 3022 Then
' Ignore the data error.
intResponse = acDataErrContinue
' Set the timer handler and interval.
Me.OnTimer = "=BumpTheNumber()"
Me.TimerInterval = 1
End If
End Sub
Private Function BumpTheNumber()
' Designed by ChrisO.
' This Error trap is required, do not turn it off.
On Error GoTo ErrorHandler
' Cancell the timer until next required.
Me.TimerInterval = 0
' Create a VBA error and stay in loop until fixed.
Me.Dirty = False
ExitProcedure:
Exit Function
ErrorHandler:
' Bump the number and resume to try again.
Me!PO = Me!PO + 1
Resume
End Function
Private Sub CmdNew_Click()
If (conHandleErrors) Then On Error GoTo ErrorHandler
DoCmd.GoToRecord , , acNewRec
ExitProcedure:
Exit Sub
ErrorHandler:
DisplayError "CmdNew_Click", Me.Name
Resume ExitProcedure
End Sub