LanaR
Member
- Local time
 - Tomorrow, 02:52
 
- Joined
 - May 20, 2021
 
- Messages
 - 113
 
I'm populating an unbound text box from a column in a combo box. This combo is selecting a suburb from a rowsource dependent on the country of origin.
For each country, the post code is a fixed numeric length. Each of the tables is formatted to show the leading zero, and this displays just fine in the combos dropdown list. This formatting gets lost, however, when the value is passed to the unbound text box.
Based on the formatting in the table, I figured the following code in the On Current event should do the trick, but I seem to be missing something as it's not having the desired effect
	
	
	
		
 For each country, the post code is a fixed numeric length. Each of the tables is formatted to show the leading zero, and this displays just fine in the combos dropdown list. This formatting gets lost, however, when the value is passed to the unbound text box.
Based on the formatting in the table, I figured the following code in the On Current event should do the trick, but I seem to be missing something as it's not having the desired effect
		Code:
	
	
	Dim PCOdeFmt As String
    
        If IsNull(Me.CountryID) Then
            Exit Sub
        End If
    
        PCOdeFmt = Nz(DLookup("PCodeFrmt", "TBL_UNCountry", "CountryID = " & Me.CountryID), "Null")
        Select Case PCOdeFmt
        
        Case "Null"
        
        Case "NNN"
            Me.Text21.Format = "000"
        
        Case "NNN NN"
            Me.Text21.Format = "000 00"
        
        Case "NNN NNN"
            Me.Text21.Format = "000 000"
        
        Case "NNN NNNN"
            Me.Text21.Format = "000 0000"
                
        Case "NNNN"
            Me.Text21.Format = "0000"
        
        Case "NNNNN"
            Me.Text21.Format = "00000"
        
        Case "NN-NNN"
            Me.Text21.Format = "00-000"
        
        Case "NNNNNN"
            Me.Text21.Format = "000000"
        
        Case "NNN-NNN"
            Me.Text21.Format = "000-000"
            
        End Select