Create a record upon opening form

Ask a Question related to Microsoft Access, Design and Development.

  1. #1

    Default Create a record upon opening form

    Is there a way to create a new record in a table via query, code, property,
    etc. without directly populating a field with data?

    For example:

    tblSomething
    ----------------------
    SomethingID PK (autonumber)
    SomethingDate
    SomethingElse

    tblOther
    ------------------------
    OtherID PK
    SomethingID FK
    OtherStuff
    OtherData

    Now, lets say that SomethingDate and SomethingElse are derived in some
    fashion, or better yet, just dependent upon OtherStuff and OtherData. I
    want to create a record in tblSomething "behind-the-scenes" without the
    users input or knowledge really.

    Everything I try doesn't work because no record exists in tblSomething. And
    that is just what I want -- to create the record!

    I hope I have explained my question well enough.

    Thanks for the help
    Sean


    Sean Guest

  2. Similar Questions and Discussions

    1. Change form record to match another form
      I had a form with a lot of controls/subforms and this was causing my database to move slow. I decided to split the controls on two forms. Each...
    2. Auto create record in subform
      In the calculation that gets the balances try using the Nz function. Nz(variant) You don't mention how you get the balances. (a VBA function is...
    3. Create simple form to add a record
      I'm a new Access user. I have a table and want to create a simple form that will allow me to add records to the table. I have all the appropriate...
    4. look up record using ste values from one form on another form
      it did not work here is the code i am using with the code you sent the command below operates off of a command button to find the record i want i...
    5. create record (in subform) automatically
      Hi all I'm beginning to think in the wrong way, so I need help. In an Access 2000 database I have two (very) related tables, Invoices and Amount...
  3. #2

    Default Re: Create a record upon opening form

    Sean:

    In the Form Load event, DoCMD.OpenQuery "appendqueryname"

    When the form loads, it runs the append query that creates/inserts a record
    into the desired table. The query selects all the needed information from
    its sources.

    I assume you are opening this form from another? You probably are going to
    need to pass parameters to your append query based upon information in the
    main form.

    If you mean create a blank record in a table, I'd have to ask why?


    "Sean" <smartin70@hotmail.com> wrote in message
    news:OUHF0qxRDHA.1576@TK2MSFTNGP12.phx.gbl...
    > Is there a way to create a new record in a table via query, code,
    property,
    > etc. without directly populating a field with data?
    >
    > For example:
    >
    > tblSomething
    > ----------------------
    > SomethingID PK (autonumber)
    > SomethingDate
    > SomethingElse
    >
    > tblOther
    > ------------------------
    > OtherID PK
    > SomethingID FK
    > OtherStuff
    > OtherData
    >
    > Now, lets say that SomethingDate and SomethingElse are derived in some
    > fashion, or better yet, just dependent upon OtherStuff and OtherData. I
    > want to create a record in tblSomething "behind-the-scenes" without the
    > users input or knowledge really.
    >
    > Everything I try doesn't work because no record exists in tblSomething.
    And
    > that is just what I want -- to create the record!
    >
    > I hope I have explained my question well enough.
    >
    > Thanks for the help
    > Sean
    >
    >
    >

    Greg Doudna Guest

  4. #3

    Default Re: Create a record upon opening form

    Thank you Keith and Greg, I will give this append query and SQL a try.
    Hopefully, one or both will work.

    The reason I need to create a "blank" record (and maybe you can offer a
    different solution) is because I have a strange 1 to many situation where
    the "many" is produced first and the "one" is determined by characteristics
    of the "many". What I exactly have is a bunch of boxes that are to be
    shipped out. They need to have a shipment number, date, etc. BUT, I do not
    want the user to enter this information. In order to be user
    "mistake-limiting", (and believe me it needs to be) I want a simple button
    that says "SHIP" -- and BAM! it creates the shipment number, date, etc.

    I've tried a very simple situation where I took a "many" table with some
    data and tried to concatenate two fields to create data to be filled in the
    "one" table. No such luck.

    Thanks again, I'll give your suggestions a try and see what I can do.
    Sean




    "Sean" <smartin70@hotmail.com> wrote in message
    news:OUHF0qxRDHA.1576@TK2MSFTNGP12.phx.gbl...
    > Is there a way to create a new record in a table via query, code,
    property,
    > etc. without directly populating a field with data?
    >
    > For example:
    >
    > tblSomething
    > ----------------------
    > SomethingID PK (autonumber)
    > SomethingDate
    > SomethingElse
    >
    > tblOther
    > ------------------------
    > OtherID PK
    > SomethingID FK
    > OtherStuff
    > OtherData
    >
    > Now, lets say that SomethingDate and SomethingElse are derived in some
    > fashion, or better yet, just dependent upon OtherStuff and OtherData. I
    > want to create a record in tblSomething "behind-the-scenes" without the
    > users input or knowledge really.
    >
    > Everything I try doesn't work because no record exists in tblSomething.
    And
    > that is just what I want -- to create the record!
    >
    > I hope I have explained my question well enough.
    >
    > Thanks for the help
    > Sean
    >
    >

    Sean Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139