Hi
I am writing a simple application which has two text boxes for user input (textbox1 and textbox2). Textbox1 has tabindex set to 1, textbox2 has tabindex set to 2. There is also a label which for some reason is set to 3. Obviously only want the tab to work between the text boxes. Does setting the label tabindex to 0 disable the tabindex to the label?
The application writes the values from the text boxes once the user leaves textbox 2. This is where the problem starts.......
If after leaving textbox2 by using the mouse to re-select textbox1, the programme works and writes the values into the access database. However, if I use the tab to leave textbox2 the programme crashes on the "command.ExecuteNonQuery" (Field 'Table1.Barcode1' cannot be a zero length strength). Using the debug stepinto routine it appears to be running the textbox2.leave event again. Below is the code from the textbox2.leave event:-
Private Sub TextBox2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Leave
' create a new oledb connection
Dim connection As OleDb.OleDbConnection = NewConnection()
' create a new command objet
Dim command As OleDb.OleDbCommand = connection.CreateCommand
command.CommandText = "INSERT INTO Table1(Barcode1, Barcode2) " & _
"VALUES('" & Me.TextBox1.Text & "', " & _
"'" & Me.TextBox2.Text & "')"
connection.Open()
command.ExecuteNonQuery()
connection.Close()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
Any ideas?
Thank you in advance.
I am writing a simple application which has two text boxes for user input (textbox1 and textbox2). Textbox1 has tabindex set to 1, textbox2 has tabindex set to 2. There is also a label which for some reason is set to 3. Obviously only want the tab to work between the text boxes. Does setting the label tabindex to 0 disable the tabindex to the label?
The application writes the values from the text boxes once the user leaves textbox 2. This is where the problem starts.......
If after leaving textbox2 by using the mouse to re-select textbox1, the programme works and writes the values into the access database. However, if I use the tab to leave textbox2 the programme crashes on the "command.ExecuteNonQuery" (Field 'Table1.Barcode1' cannot be a zero length strength). Using the debug stepinto routine it appears to be running the textbox2.leave event again. Below is the code from the textbox2.leave event:-
Private Sub TextBox2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Leave
' create a new oledb connection
Dim connection As OleDb.OleDbConnection = NewConnection()
' create a new command objet
Dim command As OleDb.OleDbCommand = connection.CreateCommand
command.CommandText = "INSERT INTO Table1(Barcode1, Barcode2) " & _
"VALUES('" & Me.TextBox1.Text & "', " & _
"'" & Me.TextBox2.Text & "')"
connection.Open()
command.ExecuteNonQuery()
connection.Close()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
Any ideas?
Thank you in advance.