Hi,
The db that's used as our corporate non conformace register, uses a NCF
numbering system based on yy-xxxx. The yy is calculated using the year
(sorry seems a bit obvious) and the xxxx bit is calculated for the next
new NCF by adding 1 onto the previously recorded number. What I want
to do is enter the main table and manually add a higher number so that
when a new procedure is implemented, we are starting from a known entry
# and date. What I cannot work out, is even though I can enter the
main table and add the number I want, when using the form to then make
a new entry, the form's not working off the number I've ented. By
that, as it stand now, if a new entry is 06-1001, the next one will be
06-1002. If I wanted to manually add one as 06-1500, the forms not
incrementing to 06-1501. Any ideas? The codes below if it's any help.
Private Sub New_NCR_Click()
Dim rst, NCRNumber, strcriteria, DDate, ddatestart, ddateend
Dim stDocName As String
Dim stLinkCriteria As String
Dim dbs As Database
DDate = Format(Date, "yy")
Set dbs = CurrentDb
Set rst = dbs.OpenRecords et("NCR_Table New", dbOpenDynaset)
For NCRNumber = 1 To 9999
strcriteria = "[NCR] = " & "'" & DDate & "-" & Format([NCRNumber],
"0000") & "'"
With rst
.FindFirst strcriteria
If .NoMatch Then
Exit For
End If
End With
Next NCRNumber
stDocName = "NCF Form"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
Forms![NCF Form]![NCR] = DDate & "-" & Format(NCRNumbe r, "0000")
Forms![NCF Form]![Date Initiated] = Date
DoCmd.Save
Forms![NCF Form]![Type].SetFocus
End Sub
The db that's used as our corporate non conformace register, uses a NCF
numbering system based on yy-xxxx. The yy is calculated using the year
(sorry seems a bit obvious) and the xxxx bit is calculated for the next
new NCF by adding 1 onto the previously recorded number. What I want
to do is enter the main table and manually add a higher number so that
when a new procedure is implemented, we are starting from a known entry
# and date. What I cannot work out, is even though I can enter the
main table and add the number I want, when using the form to then make
a new entry, the form's not working off the number I've ented. By
that, as it stand now, if a new entry is 06-1001, the next one will be
06-1002. If I wanted to manually add one as 06-1500, the forms not
incrementing to 06-1501. Any ideas? The codes below if it's any help.
Private Sub New_NCR_Click()
Dim rst, NCRNumber, strcriteria, DDate, ddatestart, ddateend
Dim stDocName As String
Dim stLinkCriteria As String
Dim dbs As Database
DDate = Format(Date, "yy")
Set dbs = CurrentDb
Set rst = dbs.OpenRecords et("NCR_Table New", dbOpenDynaset)
For NCRNumber = 1 To 9999
strcriteria = "[NCR] = " & "'" & DDate & "-" & Format([NCRNumber],
"0000") & "'"
With rst
.FindFirst strcriteria
If .NoMatch Then
Exit For
End If
End With
Next NCRNumber
stDocName = "NCF Form"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
Forms![NCF Form]![NCR] = DDate & "-" & Format(NCRNumbe r, "0000")
Forms![NCF Form]![Date Initiated] = Date
DoCmd.Save
Forms![NCF Form]![Type].SetFocus
End Sub
Comment