• SQL, Form ? (Access 97)

    Author
    Topic
    #360459

    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];”

    Viewing 0 reply threads
    Author
    Replies
    • #542809

      >>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.

      • #542854

        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.

        • #542885

          >>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.

    Viewing 0 reply threads
    Reply To: SQL, Form ? (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: