Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Claim Tag Tracker - use next tag in new record

Status
Not open for further replies.

Denae

Instructor
Apr 15, 2016
29
US
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:
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.
 
strNext is the name of the field on the form that has the next ID?
If so try
Claim_Tag_ID = strNext.value
 
I tried putting .value but it still isn't working. Right now I have the code in the GoFocus event for the Claim_Tag_ID field...where is the right place for this to trigger
 
I added the following to the AfterUpdate property of the form...not sure which one works but it updates the strNext field when it goes to the new record.

Me.Refresh
Me.Repaint
Me.Requery

So it fixed my problem...but not sure why.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top