code for command buttons on forms

wildexodus

Registered User.
Local time
Today, 08:52
Joined
Feb 6, 2003
Messages
74
I have two forms, frmCustomer and frmOrder. Frmcustomer inputs customer details, frmOrder inputs order details and also has a subform to input different products for each order. All of this is working fine.

I have a primary key in tbl customer called customerID and this is also a foreign key in tblOrder. What i need to do is put a button on frmCustomer that will open frmOrder and take whatever the CustomerID is on frmCustomer and copy it to frmOrder.

Is this possible?
 
Make frmOrders a subform of frmCustomers and it will be automatic, just like it is between frmOrders and frmProducts.

hth,
Jack
 
how do i do that? Do you mean on a whole new form or can i do it leaving them as separate forms but linking them in some way?
 
You can do it either way, but generally speaking you will want to select a Customer in your main form and then add an Order for the Customer by using the subform. You can add the Orders form to the Customer form just like you did when you added the Products subform to the Orders form.

hth,
Jack
 
i think i understand what you are saying now. Thanx, ill try that.
 
You are welcome... Check out the Orders form in the Northwind database that comes with Access as this is what I think you want to do.

Good luck...

Jack
 
god what a mess....

Its just not working. I can input the customer details and the order details on 'frmcustomer2' but when i go to 'frmOrder3' it doesnt look up the order ive already put in. It will only create new ones. I think the problem might be that although i have put in a relationship between CustomerID in tblCustomer and CustomerID in tblOrder, i couldnt enforce referential integrity because if i do something else doesnt work.
 
This is my system. Obviously the records stored in the tables are rubbish.
 

Attachments

frmOrder3 has the Data Entry property set to Yes and that is why it only allows data entry. Change that property to No.

You can't add referential integrity beween Customers and Orders because the records do not match up. Detete the records in tblOrders, set your join then start again.

You are getting there, just hang on....

Jack
 

Users who are viewing this thread

Back
Top Bottom