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

    Unanswered: combobox to select record

    Hi guys... I am not sure what the issue is here, but maybe somebody could help me. I was using this code before and it was working.... and now it isnt. I cant figure out what I changed or what is tripping it up.... i was writing other code that was changing some of the form properties but i have tried changing things back and still i cannot get it to work, does anyone know what it would be?


    I have an unbound combobox whose rowsource is a query for the primary key of the form's controlsource. I want the combobox to select the respective record in the form. "partno" is the field and "rpartno" is the combobox. it is a string.


    Code:
    Sub rpartno_AfterUpdate()
        Dim rst As DAO.Recordset
    
        Set rst = Me.RecordsetClone
        rst.FindFirst "[partno] = '" & rpartno.Value & "'"
      
        If Not rst.NoMatch Then
            Me.Bookmark = rst.Bookmark
        End If
    
    End Sub
    The code executes without an error, but the record does not change in the form.

    Any help is appreciated, thanks.

  2. #2
    Join Date
    Jun 2008
    Posts
    28
    hmm it seems as .nomatch is returning as true..., however I know that the record exists because it is based off of a query from the same table and field... any ideas?

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Could be any number of things.

    My first suspect is that the combo box isn't configured correctly.
    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

  4. #4
    Join Date
    Jun 2008
    Posts
    28
    hmm.... i dont see what it could be on the combo box... i am using the following in the data properties tab

    Control Source: ""
    Row Source: "SELECT [094bl].[partno] FROM 094bl; "
    Row Source Type: "Table/Query"
    Bound Column: 1
    Limit To List: Yes
    Allow Value list Edits: No
    Inherit Value List: Yes
    Show Only Row Source Values: Yes
    Enabled: Yes
    Locked: No
    Auto Expand: Yes

    For the form (which is a subform btw, however all of these controls and this code is all from the subform only) I have Allow Edits, Filters, and Deletions set to Yes, and Additions and Data Entry set to No. The Record source is 094bl and its a dynaset

    any ideas? Thanks

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Ok, a subform... now my second suspect is that the subform can't show you the record you want because it isn't "sub" to the mainform. What are the Link Child Field and Link Master Field properties set to for the subform object? What is on the mainform?

    You could try this code to get some output on whether the record was found or not...

    Code:
    Sub rpartno_AfterUpdate()
        Dim rst As DAO.Recordset
        Set rst = Me.RecordsetClone
        rst.FindFirst "[partno] = '" & rpartno.Value & "'"
      
        If Not rst.NoMatch Then
            MsgBox "Found a Record for " & rpartno.Value
            Me.Bookmark = rst.Bookmark
        Else
            MsgBox "Record Not Found."
        End If
    End Sub
    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

  6. #6
    Join Date
    Jun 2008
    Posts
    28
    the forms are not linked in any way... the form is a subform to a main form that just contains that form.... the form in question is simply bound to a table which i want to navigate through using the combobox

    i already know that the record is not being found, but the thing that stumps me is why... the rowsource for the combobox is looking at THE table and THE field that it is looking for

  7. #7
    Join Date
    Jun 2008
    Posts
    28
    hmm ok.... well it apprently is something with the subform thing.... if i open up the form on its own, the code works...

    the main form has no controlsource or recordsource and is simply an interface with some options... but other than that doesnt really interact with the form that much?

  8. #8
    Join Date
    Jun 2008
    Posts
    28
    bah i figured it out.... thanks lol

    it was actually a problem with linking the subform.... i just didnt know it was being linked lol

    thanks again for your help and patience

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Hehehe... at least I put you on the right track

    And 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
  •