Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form/subform problem (Access 97)

    I have an order entry form based on a query that includes a subform which lists the products ordered. My main form has an autonumber text box to assign the Order ID. My subform is based on a different query but includes an Order ID field. I have linked the two forms with the Order ID fields. (I followed the Orders form and subform in the Northwind database). When I open my form my Order ID field is populated but when I try to go to the subform I get an error message that says "The index/primary key can't contain a null value". As far as I can tell I have followed the Northwind example but cannot figure out why that one works and mine doesn't. Any ideas would be greatly appreciated!

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: form/subform problem (Access 97)

    Is this happening when you create a new record on the mainform, or just moving to the subform from an existing record? Does the info in the subform properly display before moving to it? Do you know if the error is coming from the mainform or subform?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form/subform problem (Access 97)

    Thanks Mark for replying so soon. It happens in both instances. When I try to move to the subform (it is on a separate tab) and when I try to move to a new record. I have not been able to enter any info on the subform. I pick a customer and my order number populates (autonumber). I can fill in other information on this tab but when I try to move off of it I get the error message. I tried deleting the tab with the subform and I still get the error message so it must be the main form. Is it possible that the record is not being saved so Access thinks the primary key field is null?

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: form/subform problem (Access 97)

    What is the primary key of the main form?
    If this is turning into a real problem, why don't you post the DB and we can take a look for you.
    PAt <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form/subform problem (Access 97)

    The primary key field is Order No. These forms are part of a very large database but I will try to separate out what I need and post it.

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: form/subform problem (Access 97)

    One of the conveniences of working with a bound form is that Access automatically saves the information for you. This occurs when you try to move off the current record (such as moving to a another or new record) or when you move to a subform. If the primarykey is an autonumber field, then this shouldn't be a problem. If it isn't, then you have to make sure you have filled in the data in that field. Alternatively, you might have some code in your form's BeforeUpdate event that is triggering your problems.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form/subform problem (Access 97)

    How do you "bind" a form? I've never paid much attention before, but it seems by your comment as if you have a choice of working with a bound or unbound form. How do you set it as bound? Assign a primary key and create a relationship to another table?

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: form/subform problem (Access 97)

    A bound form is one that has a value in its recordsourcce property, either a table or query name or a SQL string. With a bound form, you can also bind controls to fields in the uderlying recordset. If a form doesn't have a recordsource, it is an unbound form and you will have to create code to move between records and populate the individual controls.

    Primary keys and relationships are for tables, not forms. Forms are just windows into data.
    Charlotte

  9. #9
    Lounger
    Join Date
    Jan 2001
    Location
    New Orleans, Louisiana
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form/subform problem (Access 97)

    Sorry it took so long to reply - was out of the office. My problem apparently was in the code on an AfterUpdate procedure on my Customer Name control. I was trying to populate my ship to name and address after selecting my Customer Name. Once I deleted this I could move to my subform without an error message. Will have to work on the AfterUpdate code. Thanks for your help.

Posting Permissions

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