Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2010
    Posts
    18

    Unanswered: How do you specify the destination table?

    I've got a form that retrieves info from various tables, does lookups and accepts user entry. I've read up on joins and relationships but I don't understand how the form knows where to put the data.

    Example: I have data from Table A and Table B in my form, I want to save it all as a record in table C.

    How do you specify the destination table for the data in the form?

    There must be an INSERT INTO statement somewhere? Where would I put it, do I need one for each field or one long one pasted somewhere.

    Thanks - rev

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Generally, the form knows where to put the data because the Record Source property of the form is set to the table (or query). That's what's called a bound form, and it's the easiest and most common way of getting data to/from tables.

    In some circumstances, an unbound form makes sense. If yours is one of those, you would typically have a button that would execute an SQL statement (INSERT INTO...) to add the record (all fields at once). You could also use a recordset instead of SQL.

    You can search on unbound forms if you want more info on methods to do it that way. It is significantly more work than using a bound form. I only do it when the circumstances require it.
    Paul

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If the form is bound to a data source (table or query) by its RecordSource property and if the data controls of the form (text boxes, combo boxes, option groups, etc) are bound to the columns (fields) of that data source by their ControlSource property, the added or modified data will be automatically stored in the table(s) of the data source, except if this data source or the form itself is read-only.

    If the form is not bound to a datasource, you must provide a mechanism, using VBA, to write the data to the table(s) where you want to store them. There are several methods. You can use a RecordSet and its AddNew and Edit methods, or you can use SQL statements.
    Have a nice day!

  4. #4
    Join Date
    Aug 2010
    Posts
    18
    Pbaldy:

    >the form knows where to put the data because the Record Source property

    So all I have to do is put the destination column name in the Record Source!?

    Having the destination in the Source is like 'Press Enter to Exit'

    Can that be right?

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The form's record source property would be the name of the table, the textbox control source property would be the name of the field (column) in that table.
    Paul

  6. #6
    Join Date
    Aug 2010
    Posts
    18
    Paul:

    Thank you, thank you! I'm going to run away and try it.

Posting Permissions

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