Using MS Access back end. The ID field is a text field of 4 characters. 4 characters are required, and so if a product ID has less than 4 characters, the ID field gets padded to make 4 characters:
Private Sub IDTextBox_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles IDTextBox.Validating
While Len(IDTextBox.Text) < 4
IDTextBox.Text = CStr("0" + CStr(IDTextBox.Text))
End While
End Sub
When the user clicks the Save button to save the data, the leading zeros are dropped.Private Sub SaveData() Me.Validate()
Me.TblProductsBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.StewardDataSet)
End Sub
Why does this happen? And how do I overcome this?