Add New Contact Name

scouser

Registered User.
Local time
Today, 06:10
Joined
Nov 25, 2003
Messages
767
Hi Guys. I have a form 'frmPurchaseOrders'. The user selects a Supplier from a combo. The form contains a control 'ContactID'. I want the user to be able to add a new Supplier Contact. I have added a cmd 'cmdNewContact'. When clicked I want the Supplier form to open on the relevant supplier. I added this code to the cmd:
Code:
On Error GoTo Err_cmdNewContact_Click

    Dim strDocName As String

    strDocName = "frmSuppliers"
    
        DoCmd.OpenForm strDocName, , , [SupplierID] = [Forms]![frmPurchaseOrders]![tblSuppliers.SupplierID] 'I have 2 supplier ID's on the form
        DoCmd.Close acForm, "frmPurchaseOrders"
    
   ' Give CompanyName control focus.
    Forms![frmSuppliers]!CompanyName.SetFocus
    
Exit_cmdNewContact_Click:
    Exit Sub
    
Err_cmdNewContact_Click:
    MsgBox Err.Description
    Resume Exit_cmdNewContact_Click

frmSuppliers opens but not on the desired record (where supplier id equals the suppliers id of the purchase orders form).
Any ideas?
Cheers,
Phil.
 
Could try this

Dim strLinkCriteria As String

strLinkCriteria = "[FieldName] = Forms![FormName]![FieldName]"

DoCmd.OpenForm strDocName, , strrLinkCriteria

Hope that helps
 
Thanks

Thanks for the reply. I will give that a whirl in the morning.
Phil.
 
Hi Scouser

From reading one of your posts earlier i downloaded your car db. When you select the 'Make' the 'Model' combo changes to suit the make of the car. I tried that out, and it works fine....thats until you try to add a new record. The following msg appears: You cannot add or change a record because a related record is required in table '.........'. Have you managed to fix this??

I have something similar and i get the same msg, even though there is a related record...any ideas?

Cheers :confused:
 
Works for me?

I just downloaded to check and it works fine for me? See attached.
Regards,
Phil.
 

Attachments

Hi Phil

Downloaded it again, still getting a problem when try to enter a second record. 'You cannot add or change a record because a related record is required in table 'tblOrders'.

Entering the first record works fine...
 

Users who are viewing this thread

Back
Top Bottom