Results 1 to 5 of 5

Thread: PK in Access table?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Stockholm, Sweden
    Posts
    316

    PK in Access table?

    Hi,

    I´m trying to move up from Access to VB. In an access db I have a table with an autonumber(PK) and a text field.

    I´ve managed the database connection and I use a datagrid for the table. Now when I add a record by writing something in the text field, I want the autonumber to increment like in access.

    How do I do this? I´ve tried searching the forum, but with no luck. I´m guessing this is so easy that there isn´t even a thread for it.

    I´m using VB 2005 express.

    Thanks!

    Fuga.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    396

    Re: PK in Access table?

    Hi Fuga;

    Now when I add a record by writing something in the text field,
    I want the autonumber to increment like in access.
    The autonumber field will automatically increment as soon as you

    - Select it with the mouse, tab into it etc
    - Enter data in your text field
    - Will continue to increment if you select and deselect it several times.

    I'm not sure what your reference to moving up from Access to VB refers to. Access is a database and VB is a programming language. The two are not the same.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Stockholm, Sweden
    Posts
    316

    Re: PK in Access table?

    Thanks for your answer.


    The autonumber field will automatically increment as soon as you

    - Select it with the mouse, tab into it etc
    - Enter data in your text field
    - Will continue to increment if you select and deselect it several times.
    The thing is, it doesn´t. I thought it would but it doesn´t. If I pout something in the text field, the autonumber doesn´t follow, so the post cannot be saved.

    My databases tend to be more and more like programs, so I thought I might as well turn them into "real" programs. Otherwise I´m quite happy with Access.

    Fuga.

  4. #4
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    396

    Re: PK in Access table?

    Hi Fuga;

    I created a simple two column table with an autonumber primary key to test it before I posted and it worked with no problems.

    Are you sure that your PK field is in fact an autonumber field?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Stockholm, Sweden
    Posts
    316

    Re: PK in Access table?

    I made a new dataconnection, and now it works!

    I must have made a mistake somewhere. The field was an autonumber however.

    Thanks!

    Fuga.
    Last edited by Fuga; Apr 5th, 2007 at 11:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width