I have a database that is tracking items that are being checked in and out during a festival. Each item is tagged with a unique ID (ITM_2016_####) and plastic claim tag. I have a set list of claim tag IDs that can be assigned to items as they are entered into the system.
On a form I list each person who is checking in items then on a tabbed subform I enter the assigned tag ID and description of the item. I am trying to assign the next tag number in the series automatically and just can't get the database to do this.
I created a query that groups the remaining ID's and only shows the next one in the series and I can use this as the default value for the field, however when I add a second record it keeps the same tagID and doesn't refresh to the next one, it doesn't register that I just used the TagID.
Here is my basic structure:
tblOwners: strOwnerID | strOwnerFirst | strOwnerLast
tblTags: strTagID
tblAssignedTags: strTagID | strOwnerID | strItemDescription
Here is the query I am using to show the next TagID:
I have a field on the subform (strNext) that pulls the value on the query: =DLookUp("MinOfClaim_Tag_ID","qryNextClaimTag")
I then tried to set the value of the new record to this field. I have tried adding the following code to the OnEnter property of the subform, the OnClick property of the subform, and the GotFocus property of the field and none of these work.
Any help would be greatly appreciated.
On a form I list each person who is checking in items then on a tabbed subform I enter the assigned tag ID and description of the item. I am trying to assign the next tag number in the series automatically and just can't get the database to do this.
I created a query that groups the remaining ID's and only shows the next one in the series and I can use this as the default value for the field, however when I add a second record it keeps the same tagID and doesn't refresh to the next one, it doesn't register that I just used the TagID.
Here is my basic structure:
tblOwners: strOwnerID | strOwnerFirst | strOwnerLast
tblTags: strTagID
tblAssignedTags: strTagID | strOwnerID | strItemDescription
Here is the query I am using to show the next TagID:
Code:
SELECT tblClaimTags.Claim_Tag_ID, Min(tblAvailableClaimTags.Claim_Tag_ID) AS MinOfClaim_Tag_ID
FROM tblAvailableClaimTags LEFT JOIN tblClaimTags ON tblAvailableClaimTags.Claim_Tag_ID = tblClaimTags.Claim_Tag_ID
GROUP BY tblClaimTags.Claim_Tag_ID
HAVING (((tblClaimTags.Claim_Tag_ID) Is Null))
ORDER BY Min(tblAvailableClaimTags.Claim_Tag_ID);
I have a field on the subform (strNext) that pulls the value on the query: =DLookUp("MinOfClaim_Tag_ID","qryNextClaimTag")
I then tried to set the value of the new record to this field. I have tried adding the following code to the OnEnter property of the subform, the OnClick property of the subform, and the GotFocus property of the field and none of these work.
Code:
Private Sub Form_GotFocus()
If Nz(Claim_Tag_ID) Then
Claim_Tag_ID = strNext
End If
End Sub
Any help would be greatly appreciated.