Sam Summers
Registered User.
- Local time
 - Today, 08:06
 
- Joined
 - Sep 17, 2001
 
- Messages
 - 939
 
Hi,
I have a combobox (SubSection) and when it is updated it uses this code:-
	
	
	
		
which should create a unique number in the Item field which concatenates both the associated prefix and a generated number.
What I am trying to do with the code below is generate a number beginning from one for each prefix?
The prefix letters are uppercase and may contain from 2 to 4 letters.
Any idea where I am going wrong? Many thanks in advance!
	
	
	
		
 I have a combobox (SubSection) and when it is updated it uses this code:-
		Code:
	
	
	Private Sub DROPSSubSection_Click()
Me.Prefix = Me.DROPSSubSection.Column(2)
Me.Item = [Prefix] & "" & [Number]
End Sub
	which should create a unique number in the Item field which concatenates both the associated prefix and a generated number.
What I am trying to do with the code below is generate a number beginning from one for each prefix?
The prefix letters are uppercase and may contain from 2 to 4 letters.
Any idea where I am going wrong? Many thanks in advance!
		Code:
	
	
	Private Sub Form_Current()
    If Me.Ref = 0 Or IsNull(Me.Ref) Then
        'Me.Ref = Nz(DMax("Ref", "TOItem"), 0) + 1      'Me.YourCounterField = Nz(DMax("YourCounterField", "YourTableName"), 0) + 1
        Me.Ref = Nz(DMax("Ref", "TOItem", "Prefix = " & Chr(34) & Ref & Chr(34)), 0) + 1
    End If
End Sub