Hi
I have a Query and a form which shows records on a table where a Table field matches a field on a subform(ATRNumber). The records outputted by the query are mainly identical records.
I want to be able to add a unique string(generated by a DO Loop based on a count of records with matching ATRNumbers) to a blank field of these records.
I have seen examples of where you can go to next records till the end of file. But this would be no use as the table holds records that have different ATRNumbers.
Any help would be greatly appreciated.
I have a Query and a form which shows records on a table where a Table field matches a field on a subform(ATRNumber). The records outputted by the query are mainly identical records.
I want to be able to add a unique string(generated by a DO Loop based on a count of records with matching ATRNumbers) to a blank field of these records.
Code:
Private Sub Command8_Click()
Dim Total As Integer
Dim Num As String
Dim Prefix As String
Dim BC As String
Dim ZC As String
Dim zeros As String
Dim lngNumberOfCharacters As Long
Total = Forms!FrmStoresDueIn!ATRSubform!CountOfATRNumber
Num = Me.BarTxt
Prefix = Me.PrefixCombo.Value
lngNumberOfCharacters = Len(BarTxt)
If (lngNumberOfCharacters = 3) Then
Do
ZC = ThreeDigit(ZC)
BC = Prefix + ZC
' SQL = "UPDATE DueInTable " & _
' "SET [BarCode] = " & BC & _
' " WHERE [ATRNumber] = Form!FrmStoresDueIn!ATRSubform!ATRNumber"
' DoCmd.RunSQL SQL
Total = Total - 1
Loop Until Total = 0
End If
End Sub
Public Function ThreeDigit(ByVal strSource As String, Optional ByVal strFormat As String = "000")
ThreeDigit = Format(Val(strSource) + 1, strFormat)
End Function
I have seen examples of where you can go to next records till the end of file. But this would be no use as the table holds records that have different ATRNumbers.
Any help would be greatly appreciated.