Consulting

Results 1 to 10 of 10

Thread: Open form and inserting data

  1. #1
    VBAX Newbie
    Joined
    Nov 2020
    Posts
    3
    Location

    Open form and inserting data

    Dear All,

    I have two databases and two forms. One is called PIP (Product Information Passport) and the other is called RMA (Return Material Authorization). Both of them can be linked by the serial number of the products.
    What I want is that I have a button on the PIP form I open the RMA form and add a new record. And insert the data of the serial number in the RMA which comes from the PIP .
    Opening a new form is okay but inserting data is still not possible automatically.

    Thanks all for help

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,227
    Location
    With VBA it is more normal to enter the data directly in to the table using a recordset.
    You do not need to open the form to do so, unless you want view the data.

    Do you need to check if the data already exists in the RMA table?

  3. #3
    VBAX Newbie
    Joined
    Nov 2020
    Posts
    3
    Location
    Dear OBP,
    No That is what I can already, I can check if the record exists.
    What I cannot do is to open the form and insert a new record and putting already some data like the serial number. Also it has more data to fil in and that's what I doing in the form manually.

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,227
    Location
    Can I ask why you have 2 databases rather than all the data in just one.
    Are the databases linked?
    The way that I would do this is to place the data in the table and then opne the form on the last record.
    The other method would be to assign the value to a Public Variable, open the form, move the form selector to a new record and then assign the value to the required field.

  5. #5
    VBAX Newbie
    Joined
    Nov 2020
    Posts
    3
    Location
    The reason why I have two databases is that they are different. One database is filled with products we are delivering and the other is when they must be repaired. The serial number is the link between them.

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,227
    Location
    That data can easily be held within one database and would take advantage of the relational aspect of Access.
    I assume that through the links that you have access to the table that your second form is based on?
    Can I see the code you use to open the form please?

  7. #7
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,315
    Location
    insert the data of the serial number in the RMA which comes from the PIP .
    That only requires a query of the PIP Data Base from the RMA Form.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  8. #8
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,227
    Location
    The problem is that the data does not exist in the RMA table or the form.
    So the query will have the data from the PIP but it still needs to be transferred to the RMA form in a new record.
    A Dlookup would also work in the form as well as a public variable, but the RMA form has to be opened on a new record.
    Which is what I am trying to establish.

  9. #9
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,227
    Location
    I also can't see why a Form/Subform wouldn't also work, unless they are using a form in continuous forms mode.

  10. #10
    While you have two databases, I would link the tables of the databases (in PIP, go to external data and link to the proper RMA table). Then on the PIP form/button, either run a query that will insert to the RMA table (which is now linked in PIP) or run a currentdb.execute 'insert Into...' line of code. I can help you with the particulars if you need me to.

Tags for this Thread

Posting Permissions

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