Open form and add new record, based on two foreign keys from previous form

PTRACER

Registered User.
Local time
Today, 17:18
Joined
Feb 18, 2008
Messages
48
I know I'm going about this completely the wrong way, so please help me with this if you can...

I have written a database that handles Computer Repairs.

When a new customer comes along, I go to the Switchboard, click "New Customer" and a form opens at a new record. I type in their details in the main form and in a subform, I type whatever computer(s) they have given me to repair. At the bottom right corner of the Computer subform is a button for New Repairs.

How do I assign the button to open the "Repair" form and create a new record, using the CustomerID and ComputerID in the Computer subform, without using a parameter query that looks at the text boxes on the Computer subform?

At the moment, I use a macro to open the form, go to a new record and set the value of "CustomerID" and "ComputerID" to whatever is written in the Computer subform. The problem is that, in order for it to work, I have to close the Computer subform manually and re-open it, else I get an Action Failed error. I've inserted DoCmd.RunCommand acSaveRecord into the button's event, but that doesn't make a difference, nor does programming the macro to close the Computer subform for me.

Many thanks to anyone who can help!
 
Hi PTracer

The way I would normally do this is on the repair form have a drop down list of customers and then select the customer and add the list of repairs.

Another way you could do this is to store the customer id and computer id in variables which can be accessed by all the forms and use them when needed.

Another way to possibly look at this is when a customer comes in, if it is an existing customer then open up the customer details form and from the customer details form have a button which links you to a repairs form where you can add view existing repairs or see a repair history. In this way you can pass whatever customer details you want to the repairs form.
 
Another way to possibly look at this is when a customer comes in, if it is an existing customer then open up the customer details form and from the customer details form have a button which links you to a repairs form where you can add view existing repairs or see a repair history. In this way you can pass whatever customer details you want to the repairs form.

I already have that implemented. Once the customer is created and I've closed the form and re-opened, I can create New Repairs without any problems at all and I can view current jobs and completed jobs. It just brings up an error message if I try to create a New Repair with a newly created customer, unless I close the Customer form.
 

Users who are viewing this thread

Back
Top Bottom