J
John Campeau
Hi,
I am trying to write an automatic number generator for an issue tracking
system.
The number should look like this:
08-06-003
Where 08 represents the workplan section related to the issue. 06 represents
the year during which the issue was created. 003 is the number of the issue
in this section.
From time to time, the Workplan changes and is allocated a new name.
I have a form that contains 2 combo boxes. 1 for the workplan and 2 for the
workplan section.
I am having difficulty with the last part of the issue number generator.
I created Query1 that contains:
workplan criteria = issueFrm!workplanCombo
workplanSection criteria = issueFrm!workplanSectionCombo
I created Query2 that counts the number of records in Query1.
Private Sub workplanSectionNoCombo_AfterUpdate() triggers the number
generator (see code below)
I created a subform that has itsNoCountQry (Query2) as a Record Source.
For some reason, the subform doesn't get updated.
As it stands, the generated number looks like this:
08-06-
Me.Refresh does not work.
Your help is much appreciated.
Private Sub workplanSectionNoCombo_AfterUpdate()
'On Error GoTo Err_workplanSectionNoCombo_AfterUpdate
Dim TheDate As Date
Dim theYear, theShortYear, itsNo_1, itsNo_2, itsNo_3, temp As String
TheDate = Now
theYear = DatePart("yyyy", TheDate)
theShortYear = Right(theYear, 2)
itsNo_1 = Me!workplanSectionNoCombo.Column(0)
itsNo_2 = theShortYear
' DoCmd.OpenQuery "itsNoCountQry"
itsNo_3 = Me!issueCountSubfrm!itsNo_3
itsNo_3Len = Len(itsNo_3)
Select Case itsNo_3Len
Case 1
itsNo_3 = "00" & itsNo_3
Case 2
itsNo_3 = "0" & itsNo_3
End Select
Me!WorkplanSection = Me!workplanSectionNoCombo.Column(1)
Me![goal] = Me!workplanSectionNoCombo.Column(2)
Me!itsNo = itsNo_1 & "-" & itsNo_2 & "-" & itsNo_3
Exit_workplanSectionNoCombo_AfterUpdate:
Exit Sub
Err_workplanSectionNoCombo_AfterUpdate:
MsgBox Err.Description
Resume Exit_workplanSectionNoCombo_AfterUpdate
End Sub
This first query gets the needed information from the itsTbl table.
itsNoCount1Qry
--------------
SELECT itsTbl.itsNo, itsTbl.workplanNo, itsTbl.workplanSectionNo
FROM itsTbl
WHERE (((itsTbl.workplanNo)=[Forms]![itsNewFrm]![workplanNoCombo]) AND
((itsTbl.workplanSectionNo)=[Forms]![itsNewFrm]![workplanSectionNoCombo]));
The second query generates the relevant number.
This query is the record source for the subform.
itsNoCountQry
I am trying to write an automatic number generator for an issue tracking
system.
The number should look like this:
08-06-003
Where 08 represents the workplan section related to the issue. 06 represents
the year during which the issue was created. 003 is the number of the issue
in this section.
From time to time, the Workplan changes and is allocated a new name.
I have a form that contains 2 combo boxes. 1 for the workplan and 2 for the
workplan section.
I am having difficulty with the last part of the issue number generator.
I created Query1 that contains:
workplan criteria = issueFrm!workplanCombo
workplanSection criteria = issueFrm!workplanSectionCombo
I created Query2 that counts the number of records in Query1.
Private Sub workplanSectionNoCombo_AfterUpdate() triggers the number
generator (see code below)
I created a subform that has itsNoCountQry (Query2) as a Record Source.
For some reason, the subform doesn't get updated.
As it stands, the generated number looks like this:
08-06-
Me.Refresh does not work.
Your help is much appreciated.
Private Sub workplanSectionNoCombo_AfterUpdate()
'On Error GoTo Err_workplanSectionNoCombo_AfterUpdate
Dim TheDate As Date
Dim theYear, theShortYear, itsNo_1, itsNo_2, itsNo_3, temp As String
TheDate = Now
theYear = DatePart("yyyy", TheDate)
theShortYear = Right(theYear, 2)
itsNo_1 = Me!workplanSectionNoCombo.Column(0)
itsNo_2 = theShortYear
' DoCmd.OpenQuery "itsNoCountQry"
itsNo_3 = Me!issueCountSubfrm!itsNo_3
itsNo_3Len = Len(itsNo_3)
Select Case itsNo_3Len
Case 1
itsNo_3 = "00" & itsNo_3
Case 2
itsNo_3 = "0" & itsNo_3
End Select
Me!WorkplanSection = Me!workplanSectionNoCombo.Column(1)
Me![goal] = Me!workplanSectionNoCombo.Column(2)
Me!itsNo = itsNo_1 & "-" & itsNo_2 & "-" & itsNo_3
Exit_workplanSectionNoCombo_AfterUpdate:
Exit Sub
Err_workplanSectionNoCombo_AfterUpdate:
MsgBox Err.Description
Resume Exit_workplanSectionNoCombo_AfterUpdate
End Sub
This first query gets the needed information from the itsTbl table.
itsNoCount1Qry
--------------
SELECT itsTbl.itsNo, itsTbl.workplanNo, itsTbl.workplanSectionNo
FROM itsTbl
WHERE (((itsTbl.workplanNo)=[Forms]![itsNewFrm]![workplanNoCombo]) AND
((itsTbl.workplanSectionNo)=[Forms]![itsNewFrm]![workplanSectionNoCombo]));
The second query generates the relevant number.
This query is the record source for the subform.
itsNoCountQry