Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2008
    Posts
    20

    Unanswered: combo box and subform problem!!

    hello,
    i am having a strange problem
    i have table with PK: name+phone number.
    i have a form which has a combo box and a subform
    combo box is used to select a name...
    on updation of this combo box the subform finds related details..
    when i click on any textbox to update etc.. i get an error "index or primary key cannot contain a Null value.

    also suppose there are more than 1 person called jim.. then i cannot go to next record.. as the same error msg keeps popping.

    next when i try closing this form i get an error message saying u cannot record this record.
    i no where try to add any new record to my table

    please suggest what might be possibly wrong

    here's the code i am using on the cobo box:

    Code:
    Sub SetFilter()
    Dim LSQL As String
     
    LSQL = "select * from FairDB"
    LSQL = LSQL & " where Name = '" & cboSelected & "'"
     
    Form_FindByName.RecordSource = LSQL
     
    End Sub
    Private Sub cboSelected_AfterUpdate()
     
    'Call subroutine to set filter based on selected CustomerID
    SetFilter
     
    End Sub
    Private Sub cmdClose_Click()
    'Close form
    DoCmd.Close
     
    End Sub
    Private Sub Form_Open(Cancel As Integer)
     
    'Call subroutine to set filter based on selected CustomerID
    SetFilter
     
    End Sub

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    What's the SQL for your mainform?
    What's the SQL for your subform?
    What are your Link Child Fields and Link Master Fields properties set to for the subform object?
    What's the Row Source SQL from your combo box?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jun 2008
    Posts
    20
    What are your Link Child Fields and Link Master Fields properties set to for the subform object?
    both Name

    What's the Row Source SQL from your combo box?
    SELECT DISTINCT [FairDB].[Name]
    FROM FairDB;

    i am not clear with what u mean by SQL of a form..

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    The form SQL is the form's Record Source or the SQL in the query referred to in the form's Record Source.

    I wouldn't be at all surprised if this turns out to be some complexity with using Name as a fieldname. Name is a reserved word and you should avoid using it.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jun 2008
    Posts
    20
    both form and subform have record source: FairDB (table with pkerson and phone no) i changed name to person on your advice.. but the problem continues

  6. #6
    Join Date
    Jun 2008
    Posts
    20
    here are the two files.. please refresh the table links
    Attached Files Attached Files

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I'm pressed for time atm,... try removing the Control Source for the combo box.

    If this doesn't work, I'll check out the db properly and get back to you.

    Off to dinner
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Jun 2008
    Posts
    20
    u are a genious....
    thank you.. thank you so much!!! my problem is solved.. thanx a lot

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Cool

    You're most welcome
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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