Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Tampa, Florida, USA
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop down list to complete portion of form

    I am a "brand new newbie" - I apologise for not knowing the correct terminology:

    I am creating my first database. I have two tables: "Contacts" (a list of names with address, phone, etc. type info) and "Events" (a list of different events each Contact has participated in).

    I have a form to enter new contact information, and a second form to enter new event information. I have a query that combines First Name field and Last Name field from the Contact table. I would like the the new event input form to have a list box displaying all the Contact Names from the first table from which the user would select the correct Contact Name for the new event information. By clicking on the selected Contact Name, the new event information entered on the form would be added to the Event Table.

    Can anyone help? Thank you very much, in advance!

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drop down list to complete portion of form

    Write some code in the ondoubleclick event of your contacts listbox. Make sure the first column in you contacts listbox is the contactid (I assume you have an autonumber key field as your contactid).
    I assume you have a text field on your form with the event in it.
    The code in the ondoubleclick event should look something like this.

    Dim db as database
    dim strSQL as string

    strSQL = "INSERT INTO tblEvents (ContactID, event) VALUES("
    strSQL = strSQL & cstr(me![lstContacts]) & ", '"
    strSQL = strSQL & cstr(me![event]) & "');"

    set db = currentdb()
    db.execute strSQL, dbFailOnError
    set db = nothing

    What happens here is that there is a SQL statement generated that looks like this:
    INSERT INTO tblEvents (field1, field2) VALUES(value1, value2);

    The SQL statement is executed on you current database.

    I hope this will help you.

  3. #3
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drop down list to complete portion of form

    I think you want to start by creating a Contact Field in the events table and linking that field to the ContactID field in your contact table. If you don't have a unique ContactID field in your contact table you should create one, autonumber will do. As far as entering contacts on your events form, try using the combo box wizard. Hope that gets you started. [img]/w3timages/icons/smile.gif[/img]

Posting Permissions

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