Morning all,
We are having an intermittent issue with our system
We have a main form where the completion details of a record are entered. We log a number of items one of which is a report number. This is a free text field as we denter duplicates on multiple records, but when a new number is required we have the following code to generate a new number from a seperate ReportNumber table:
Now for some reason, somewhat intermittently, all of the order completion information is not stored in the database and the report number is blank. When you try and complete this information again it will store everything expect the report number, where it will throw the error "no search key was found in any record"
Any clues where to start diagnosing this?
TIA
Chris.
We are having an intermittent issue with our system
We have a main form where the completion details of a record are entered. We log a number of items one of which is a report number. This is a free text field as we denter duplicates on multiple records, but when a new number is required we have the following code to generate a new number from a seperate ReportNumber table:
Code:
Private Sub addNewId()
Dim strPrefix As String, varResponse As Variant
If Mid(Me.[Report No] & vbNullString, 3, 1) = "/" Then
MsgBox "This Report No has already been generated", vbInformation + vbOKOnly
Exit Sub
End If
If OnStop = True Then
MsgBox "Client is set as On Stop. Report cannot be generated", vbInformation + vbOKOnly
Exit Sub
End If
strPrefix = Format(Now(), "yy") & "/"
Me.[Report No] = nextIdString("ReportNo", "TBLREPORTID", strPrefix)
DoCmd.OpenForm "FRMREPORTID", acFormDS, , , acFormAdd, acHidden
Forms!frmreportid!ReportNo.SetFocus
strPrefix = Format(Now(), "yy") & "/"
[Forms]![frmreportid]![ReportNo] = nextIdString("ReportNo", "TBLREPORTID", strPrefix)
DoCmd.Close acForm, "frmreportid"
End Sub
Code:
Public Function nextIdString(ByVal nisFieldName As String, ByVal nisTableName As String, ByVal nisPrefix As String) As Variant
nextIdString = Nz(DMax("[" & nisFieldName & "]", nisTableName, "[" & nisFieldName & "] Like '" & nisPrefix & "*'"), nisPrefix & "0")
' nisPrefix & "0" gives you a default value if one is not found in the table
nextIdString = Val(Mid(nextIdString, Len(nisPrefix) + 1)) + 1
' Get next numerical value by looking at the highest value number after the prefix and adding 1
nextIdString = nisPrefix & Format(nextIdString, "00000") ' create next string Id
' Create new ID string by concatenating the formated number to te prefix
End Function
Now for some reason, somewhat intermittently, all of the order completion information is not stored in the database and the report number is blank. When you try and complete this information again it will store everything expect the report number, where it will throw the error "no search key was found in any record"
Any clues where to start diagnosing this?
TIA
Chris.