Create a record upon opening form

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

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:

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?
 
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
 
Back
Top