Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005

    Red face Unanswered: accessing form from selected listbox record


    I have a listbox in a form. I am writing code for an "OK" button that will allow a record from the listbox to be chosen. When the record is selected and the OK button is clicked, the data entry form with the record in it should be displayed. The problem is: I get an error that says that the form can't be found. I know it is spelled right and is case-specific. Any guesses on what else I could be doing wrong?

    Thanks, redwhisk

  2. #2
    Join Date
    Apr 2004
    outside the rim
    Any guesses on what else I could be doing wrong?
    We'll need to know a bit more about how you're doing this. Posting the actual code would help.

    Sounds like you want to do this:
    Private Sub cmdOK_Click()
        Dim iKey As Integer
        ' This assumes the bound column of List0 contains the index, which I called YourKey in this example
        ' YourKey would be the index field of the table.
        If Len(Me.List0 & "") = 0 Then Exit Sub
        iKey = Me.List0
        DoCmd.OpenForm "YourForm", acNormal, , "[YourKey] = " & Format(iKey)
    End Sub
    have fun!

    Todd S.
    click to email

    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET

    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

Posting Permissions

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