Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a record using info from previous form

Status
Not open for further replies.

Sarah28

IS-IT--Management
Aug 6, 2000
16
US
I have a form called Sale. It has a field for called custo mer. It has a button called ShipAddr.
I want to be able to open a form called shipto from the ShippAddr button.

When Opened I want the ShippAddr form to display the Sales shipto address based on the value in the customer field on the previous form. or if one doesn't exist I would like it to add a new record for the customer.

How do I do this? Any help would be greatly appreciated.
 
Hi Sarah,

Ok there are a couple of issues here if you have a customer details table and a form based on this table, how does the shipping address relate to the customer ie is it part of the customer details??
also what do you mean if one doesn't exist, do you mean a customer entry?? and would like to add a new customer?



Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CustDetails"

If Not IsNull(Me.SelCustCode) Then
stLinkCriteria = "[Customer]![CustID]=" & Me![SelCustCode]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , , acFormAdd
End If

this code from a current project will open my customer details form based on the value in the Me.SelCustCode "Customer" field if there is no customer selected it will open the customer details form at a new record ready to add customer details, otherwise it opens the customer details at the currently selected customer. you need to change the field/form names to suit your situation.

now if there are two tables involved this makes it a little more complicated, let us know.

HTH

Robert Dwyer
rdwyer@orion-online.com.au
 
Thanks for your reply!

Sorry I was not clear enough. The shipping address is held in it's own table as it is specific to each sale, not each customer.

So I need to know how to insert the CustomerID into the new Shipping Address record that is created if their is no existing shipping address.

Thanks Again.
Sarah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top