Results 1 to 3 of 3

Thread: Sql

  1. #1
    Join Date
    Dec 2002
    Posts
    1

    Unanswered: Sql

    I am designing an Access database to keep track of addresses for my friends and family. I have 2 tables: tblAddress and tblAddressSubtype, and 2 forms: frmAddressEntryForm and frmAddressSubform. I am trying to write SQL in a combo box to pull the data from the FirstName and LastName fields from tblAddress. I have a sample of the code below:

    SELECT [tblAddress].[FirstName], [tblAddress].[LastName] FROM tblAddress ORDER BY [tblAddress].[LastName];

    The whole purpose of this may look confusing but let me elaborate. frmAddressSubform is a subform in frmAddressEntryForm and the forms are linked by a common field named ContactID. ContactID simply lists the unique ContactID I am using for each phone book entry. I want ContactID to list the FirstName and LastName field from tblAddress instead of the ContactID. Please, if someone has any suggestions please let me know, I would really appreciate it. Thanks.

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    I think what you mean is that you have a table with ContactID, FirstName, Lastname; and another table with the address details for this contact, with ContactID as the linking field.

    In this case ContactID must be included in your SQL statement to provide the link. It may be invisble, or you may choose to copy the field to your form and make the field invisible.

    HTH

  3. #3
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Sql

    SELECT [tblAddress].[ContactID], [tblAddress].[FirstName] & " " , [tblAddress].[LastName] AS Name FROM tblAddress ORDER BY [tblAddress].[LastName];

    Change the column widths to 0cm, 2cm. This will hide the contact ID and display only the name. Also make the column count 2 ....

    Hope this is what you were looking for ....




    Originally posted by Teqlump
    I am designing an Access database to keep track of addresses for my friends and family. I have 2 tables: tblAddress and tblAddressSubtype, and 2 forms: frmAddressEntryForm and frmAddressSubform. I am trying to write SQL in a combo box to pull the data from the FirstName and LastName fields from tblAddress. I have a sample of the code below:

    SELECT [tblAddress].[FirstName], [tblAddress].[LastName] FROM tblAddress ORDER BY [tblAddress].[LastName];

    The whole purpose of this may look confusing but let me elaborate. frmAddressSubform is a subform in frmAddressEntryForm and the forms are linked by a common field named ContactID. ContactID simply lists the unique ContactID I am using for each phone book entry. I want ContactID to list the FirstName and LastName field from tblAddress instead of the ContactID. Please, if someone has any suggestions please let me know, I would really appreciate it. Thanks.
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

Posting Permissions

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