Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL, Form ? (Access 97)

    I would like to have the results of the SQL statement below populate a field in a form. The form is called testform and the field is called problem1. This SQL below gets he data I want I just don't know how to have it populate the field on the form. Thanks for the help.
    Dim SQL$ As String
    SQL$ = "SELECT [Problem] FROM [EIRReview_Frm];"

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: SQL, Form ? (Access 97)

    >>SQL$ = "SELECT [Problem] FROM [EIRReview_Frm];"<<

    Your controlsource for your textbox would be this:

    =DLookup("Problem","EIRReview_Frm")

    However, without a WHERE clause in the above statement, unless your table has a single record, there is no telling which value of "Problem" you will get.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL, Form ? (Access 97)

    That does work Mark. But what if the form and the field already have a record and control souce? Basically what I'm trying to do is if the user chooses the can have the fields on form1 populate the selected fields on form 2. Does this make more sense? Thanks.

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: SQL, Form ? (Access 97)

    >>That does work Mark. But what if the form and the field already have a record and control souce? Basically what I'm trying to do is if the user chooses the can have the fields on form1 populate the selected fields on form 2. Does this make more sense?<<

    You use DLookup when you want to get the value of a field from another table. For example, if you have a CustomerNO and you want to display a CustomerName. The DLookup is not updatable, in only looks something up. So, you need 2 controls, one for data entry, and one to display the value of the DLookup.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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