Help! I'm trying to navigate previous/next through records (MS Access backend database) in a bound form. Note, this is a DataRowView (individually bound fields), not a DataGridView. I've got two related issues, but I'll handle the second issue in another post. I've got two key fields in the underlying database table. The second key field, Carrier_No, is defined as 5 characters. When I attempt to move to the previous record, the application populates the second key field with 'System.Data.DataRowView.' Then, when I click the Previous (or Next) button again, I get the following error: System.ArgumentException: 'Cannot set column 'Carrier_No'. The value violates the MaxLength limit of this column.' What am I doing wrong? This seems to be such a simple task.
-
Forgot to mention, this is VB.NET in Visual Studio Community 2019. MS Access 2010. – Jeff S Dec 10 '20 at 15:20
-
Can you provide the method that handles the previous/next record navigation, and where the properties are set for the DataRowView? Sounds like something funky is happening with the value member or other properties that tell the control what to display. – Tim Dec 10 '20 at 18:23
-
It's all about _code_ here, Jeff! Provide your code and we might help you. – Christoph Dec 10 '20 at 23:12
-
You are obviously not binding correctly. As you haven't shown us what you have done, we can't tell you what's wrong with it. Please take the site tour that you rejected when you registered and spend some time in the Help Center to learn how this site works. The sooner you learn how to post a good question, the sooner you will get the answers you want. Also, no one should have to read the comments to understand the question. If you forgot to mention something, edit your question and mention it. If someone asks a question about relevant info you omitted, edit the question and add it. – jmcilhinney Dec 11 '20 at 00:15
1 Answers
Thanks all for your responses. After much troubleshooting, I stumbled upon the solution. It turns out the combobox 'DropDownStyle' property was the culprit. I had originally set the property to 'DropDownList' to prevent users from entering a value. When I set the property to 'DropDown,' the problem went away. I have no idea why this property would have any effect on record navigation, but it does. To prevent users from entering data, I employed some code in the combobox 'KeyPress' event. As it turns out, this solution also solved a related issue (combobox values being copied to other records, separate post).
Private Sub cmb_TPA_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cmb_TPA.KeyPress MsgBox("Please select a TPA value from the pick list.", vbExclamation) e.Handled = True 'cancel event End Sub

- 21
- 3