Default Values on New Records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Coolboy55
    New Member
    • Jul 2007
    • 67

    Default Values on New Records

    I have no default value set for the StationID field on my Tasks table - in fact, I don't even have that field on my Tasks form. But when I make a new record on the form, a default value is copied into the table. When I make a new record on the table, a default value is not created.

    What could be creating that default value when I make a new record using the form, even though that field is not even on the form?

    Thanks!

    CB55
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by Coolboy55
    I have no default value set for the StationID field on my Tasks table - in fact, I don't even have that field on my Tasks form. But when I make a new record on the form, a default value is copied into the table. When I make a new record on the table, a default value is not created.

    What could be creating that default value when I make a new record using the form, even though that field is not even on the form?

    Thanks!

    CB55
    You likely have the StationID field set to autonumber in access?

    This would make it automatically populate with an incremental value every new record. This is actually a good way to keep a unique identifier in tables

    You dont need to have the value on the form, the databse will do it automatically. Also when you enter a new record in the table you said it doesn't create a value? Did you try tabbing down to the next record? Thats when the insert actually takes place and you will probably see then a value appear.

    Comment

    • Coolboy55
      New Member
      • Jul 2007
      • 67

      #3
      Originally posted by jeffstl
      You likely have the StationID field set to autonumber in access?

      This would make it automatically populate with an incremental value every new record. This is actually a good way to keep a unique identifier in tables

      You dont need to have the value on the form, the databse will do it automatically. Also when you enter a new record in the table you said it doesn't create a value? Did you try tabbing down to the next record? Thats when the insert actually takes place and you will probably see then a value appear.
      It's true that StationID is an autonumber in the Stations table, but it is a foreign key in the Tasks table and is looked up from the Stations table along with two other columns. The Tasks table does not autonumber the StationID, but for some reason I get a default value when I create a new record in my Tasks form. The default value turns out to be the same as the previous record's value for that field. It is very strange... any other ideas? :/

      CB55

      Comment

      • jeffstl
        Recognized Expert Contributor
        • Feb 2008
        • 432

        #4
        Originally posted by Coolboy55
        It's true that StationID is an autonumber in the Stations table, but it is a foreign key in the Tasks table and is looked up from the Stations table along with two other columns. The Tasks table does not autonumber the StationID, but for some reason I get a default value when I create a new record in my Tasks form. The default value turns out to be the same as the previous record's value for that field. It is very strange... any other ideas? :/

        CB55
        Im not sure. I would have to see the Tasks form code or atleast the portion of code executed when you create a new Tasks record.

        If the form is populating that column (StationID) with a number, it has to either be an autonumber or populated in the code when you save a record. Check your binded controls, check if you have any hidden controls or text boxes in design view, etc that may be holding that StationID value and passing it with the Task record being added.

        Comment

        Working...