Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    2

    Unanswered: Creating First Form - Help with Look Up

    I work with queries all day long and am trying my hand at creating a form. It isn't going too well!

    General pusrpose: My company mails advertisements, when a person calls in, we'd like to be able to have them give us their "reference number" and pull their info up from the table we used to mail.

    So... I have 1 table of people that I have mailed, complete with a Primary Key ("ref #") and about 30 other fields. I would like to have the form allow us to search by ref #, then populate the information in the other fields for that record. I will only want about 10 of the 30 fields visible. And I don't want the person to be able to edit the data at all. Once it pulls up the record I would like to append that record into a new table, along with the current date/time.

    I added some unbound lookup boxes but can't find a button that will display my values. I don't know VisualBasic. How can I get to the next step where the record appears? There's more that I'd like to do but this first part seems like it should be so simple and I can't figure it out on my own.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Bind the objects to the data.

    Set the AllowEdits, AllowDelete and AllowAdditions properties for the form to No to make the form read-only.

    Place a command button on the form to use as a trigger for finding (the code below refers to this button as cmdFindByRef.

    Use a VBA subprocedure to filter by the Ref #... eg

    Code:
    Private Sub cmdFindByRef_Click()
        Dim intFindWhat As Integer
        intFindWhat = InputBox("What reference number do you want to find?", "Find by Ref #")
        Me.Filter = "[Ref #] = " & intFindWhat
        Me.FilterOn = True
    End Sub
    This code is a bit "rough and ready" and it assumes your ref # is an integer but it should send you in the right direction at least.
    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
    Mar 2008
    Posts
    2
    Ok. When using that code, how do I specify that the "ref #" they entered is coming from that column? I don't see where I'm doing that. What is it actaully filtering?

    You know, I'm thinking I need to read a book on it before i can complete what I thought was going to be a simple task. I can usually work things out using help, I don't think that's going to be the case here. Any thoughts on that? Or suggested reading material?

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Mnnn... suggested reading material, someone else might have to answer that as I have only read the user manual from very early versions of Access.

    As for your first question, the command button would have something like "Find by REF #" written on it, so they know they are searching the ID... If I am understanding your question properly...
    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
  •