How can I add more than one new record in my pop-up form?

RSW

Registered User.
Local time
Yesterday, 17:06
Joined
May 9, 2006
Messages
178
I have built a main screen for inventory items, and a pop-up that displays/enters transactions for each of those inventory items. I use the following code:

Code:
 DoCmd.GoToRecord , , acNewRec
    Forms!Transaction.InventoryID = Me.ID

on the pop-up event to associate the new transaction record with the inventory item.

However, if I attempt to add another record to the transaction continuous form, I get an error, because Access doesn't know what the required InventoryID is for the new record.

What's the easiest way to associate the given inventoryID with every new transaction added? I attempted code similar to the above in AfterInsert code, but the Me.ID doesn't work any more, since we're no longer on the main screen. Did I do something wrong in the design of my database? Because this seems so straightforward. As far as I know, the Inventory and Transactions tables (the two main tables) do have the correct relationship set up.

Thanks in advance!
 
I am really struggling here.

I am trying to build what should be amongst the simplest of databases. Main form is a continuous form with lots of records; click a button by a given record to add rows to a different table all linked to that specific main record. That's basically it.

I can't get the secondary form to stop asking for the ID of the main record; I keep having to exit it without saving.

I can't even seem to get the right records to be displayed when the secondary form is opened; seems to be all or none.

Does anyone know of a very simple sample database that I could look at to try and determine what I've got wrong here? I checked out the official Microsoft samples...and they are all far more complicated than what I'm trying to do!

Maybe I would be successful if I used the wizards...but I hate the idea of having to re-do the entire database.
 
I am really struggling here.

I am trying to build what should be amongst the simplest of databases. Main form is a continuous form with lots of records; click a button by a given record to add rows to a different table all linked to that specific main record. That's basically it.

I can't get the secondary form to stop asking for the ID of the main record; I keep having to exit it without saving.

I can't even seem to get the right records to be displayed when the secondary form is opened; seems to be all or none.

Does anyone know of a very simple sample database that I could look at to try and determine what I've got wrong here? I checked out the official Microsoft samples...and they are all far more complicated than what I'm trying to do!

Maybe I would be successful if I used the wizards...but I hate the idea of having to re-do the entire database.

If you can post what you have, we can see about helping out. If you have Access 2007, can you try to post it in 2003 format as I don't have 2007 format here at work.
 
If you can post what you have, we can see about helping out. If you have Access 2007, can you try to post it in 2003 format as I don't have 2007 format here at work.


How would I be able to post what I have?

There is something very basic I am missing. I just tried to start from scratch and make a simple database allowing someone to populate sports teams with players:

- create table called Teams
- create table called Players
- set a relationship between ID in the Team table and TeamID in the Players table
- created continuous form based on Teams table
- created continuous form based on Players table
- put button on Teams table and used the wizard to specify opening the Players form as a pop-up, only with records where ID and TeamID matched

...and it doesn't work...the players aren't being saved with their TeamIDs, and so after you enter some, they don't come up the next time you click on the team you thought you were associating them with.

I feel like this is something very, very basic that I should be able to do in five minutes...there is apparently some key part of the process that I am forgetting!

The database I've been working on is really just a glorified version of what I just tried to do above.
 
Last edited:
How would I be able to post what I have?

1. First run compact and repair.

2. If in 2007, try going to the Big Office Button and then to SAVE AS (don't click on SAVE AS but just hover the mouse over it) and then select the DATABASE option that shows up.

3. If it lets you save it as that version then you can go to that file, right-click on it and select SEND TO > COMPRESSED FOLDER and then that will create a zip file of it. Then you go here to the GO ADVANCED button under the quick reply window and then down below there is a MANAGE ATTACHMENTS button which you then click and then a dialog pops up. You then click on the button to select the zip file, and then after selecting it, you click the UPLOAD button on that same dialog. Then click CLOSE to return to the message window and type something in.
 
Thanks Bob,

I uploaded a .zip file. This is the silly little database I described making in my last post, but if I understood how to make this one work, I would be able to do a far more complicated one! :)
 

Attachments

to do it automatically, you need this

- created SINGLE form based on Teams table, with record selectors at the bottom
- created continuous form based on Players table

add subform to the teams form - access will ask you which form, and let you pick the players form. it will THEN ask you how the data is related
(you cant have a continuous form as a subform of a continuous form)

now as you move through the teams, the players will automatically change - and if you add players, they will automatically be put in the correct team

---------
its the form/subform bit, that lets access do it automatically - not a popup. if you use the popup then you need a bit of code to save the correct team value.
 
to do it automatically, you need this

- created SINGLE form based on Teams table, with record selectors at the bottom
- created continuous form based on Players table

add subform to the teams form - access will ask you which form, and let you pick the players form. it will THEN ask you how the data is related
(you cant have a continuous form as a subform of a continuous form)

now as you move through the teams, the players will automatically change - and if you add players, they will automatically be put in the correct team

---------
its the form/subform bit, that lets access do it automatically - not a popup. if you use the popup then you need a bit of code to save the correct team value.


Darnit--I really do need two continuous forms, one being a pop-up. This seems so basic, and I was really hoping it wouldn't need any code. Do you know if there is a sample database set up like this anywhere?
 
I'm still not having any luck with this...

Trying to work with code from another database, I put in the following in the Players opening event...

Code:
 stDocName = "Players"
    DoCmd.OpenForm "Players", , , "TeamID=" & "'" & Me!ID & "'", , , Me!ID

That doesn't work either. Players I create in the Players form do not have the Team ID of the Team record I clicked, assigned.

Also, when I look at the Teams table and click the plus sign on the left, I get the error:

"This expression is typed incorrectly, or it is too complex to be evaluated..."

I don't understand what could be incorrect, or complex...I just want to have a one-to-many, parent-child relationship between Teams and Players.

A slightly updated copy is attached. Anything to point me in the right direction would be appreciated. This is driving me nuts.
 

Attachments

Users who are viewing this thread

Back
Top Bottom