Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    20

    Unanswered: adding record using form linked to another form

    I have a form customers form that brings up a projects form with the project records that have the customerID from the one chosen in the first form (customers from the customers table) - when I do an insert it adds the record that I want (from the projects form I filled out) - but it does not add the customerId field - I want it to remember it from the first form - how do I do this?

    thanks - JS



    (below explains the same thing in a question I asked via email to someone - disregard if the above problem was clear already)

    I can view all the record in the forms ok when they already exist in the table, but I am having trouble adding new ones

    When I go from the customers form and click the button to go to the projects form, but there is no project already existing for that customer, I fill out the form, but it doesn't know the customerID from the first form to do the insert with - it adds a record into the projects table fine, but the customerID field in the project is null and so the record in the project table is in no way associated with the customer (since the way they are joined is by the field CustomerID that exists in both tables)

    Where do I establish this relationship in Access?

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    one way to doing it is,
    create a mainform with customers table and add a projects subform into this main form.
    ghozy.

  3. #3
    Join Date
    Oct 2004
    Posts
    20

    Can't use subforms

    can't do it as a subform - biggest reason is that the form needs to bring up another form that brings up another form..... so since it is like 4 forms/tables deep, I think using a new form technique is better....

  4. #4
    Join Date
    Sep 2004
    Location
    Charlotte, NC
    Posts
    164

    adding record using form linked to another form

    You may want to write a procedure to copy the current value in the customer number field on the customer form, then open the project form, then paste the value into the customer number field on the project form. You could then assign the button on your customer form (that currentlly just opens the project form) to this new procedure. You would then just need to enter the remaining information about the new project just as you do now.

  5. #5
    Join Date
    Oct 2004
    Posts
    20
    I am not sure of the syntax I would use to "pull" out or store the field in a form and then "paste" it into the new form's textbox.....

    Can you give me the syntax I would need to put in for this - I don't know how to reference the field

    do I use [forms]![Customers]![CustomerID] ?

    and can I set something equal to that (above) and then I still don't know where I put in the new info - can I just say

    [forms]![Projects]![CustomerID] = [forms]![Customers]![CustomerID]

    or do I need to save it off and then reassign it after the form opens....

Posting Permissions

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