Unanswered: Add Plus One Value To Feild Value In Form
What i need to do:
For the value in my primary key field to increase by 1 when a new record is started.
Currently, when a new record is started, i have to manually enter the "Card Number" each time (Which is +1 than the previous record). I need vb code which can do this for me. (Please tell me where i place the code)
I can't use the Autonumber data type because i have some what 2000 records already in the table, and it wont allow me to change it which is why im asking for vb code.
Currently i have a form which uses a text field, linked to a primary key called "Card Number".
When i start a new record, i have to enter a card number eg, 1001239
(the previous records had the card numbers: 1001237, 1001238)
Can anyone give a code or solution as to how i achieve this?
Eh, well, if you really don't want to use autonumbering (I can't see why this won't work, even with your explanation), you should be able to order your datatable by its card number, and then take the last card number and add 1 to it.
Dim newValue as Integer = DataSet.CardsTable.Select("", "CardNumber DESC")(0)("CardNumber") + 1
Llandaff hotels? What. This is Access, right?
Microsoft Access 2007 lets me change field's datatype to Autonumber just fine, as long as there is only one autonumber field. I tried it just now on a fully populated table. I am sure 2003 lets you do that as well.
Well, I have no idea what your code looks like... You would put that code right after you create a new datarow.
You would create the datarow, and then assign the value in newValue to the "Card Number" field name.
Well, I do not have extensive experience with databases or microsoft access; however, I can tell you that it let me change fields to AutoNumber from number.
It only let me use one autonumber field, and it did not let me switch one field to another field without first saving and restarting; however, it did allow me to do it in the end, without trouble.