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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird form - subform relationship. Please help.

Status
Not open for further replies.

metrodub

Technical User
Dec 29, 2004
82
US
I have a form (frmVendorManagement) that contains 10 controls:
cboCompanyName - an unbound combobox that lists, you guessed it, Company Names.
txtVendorNumber - a textbox with cboCompanyName.Column(2) as its control source.
4 other text boxes - all with their control source set to a column from cboCompanyName
sfrmPartners - a subform that lists the partners associated with company chosen from cboCompanyName. The Link Child Fields is set at tblCompany.CompanyID and the Link Master Fields is set at cboCompanyName. This works perfectly.
cmdOpenContractInfo - a command button that opens a Contract Form (frmContractNew), showing contract data for the chosen Company. This works.
cmdCloseForm - Closes the form.

cmdEditVendor - a command button that opens the Vendor form (frmVendorNew) so that a user can edit information about the vendor (address, phone, etc). This works for most of the companies in the combobox but, for those who do not have any partners associated with them, the form opens blank (the form caption has the appropriate company name though) and any data entered becomes a new record.

This is the code to open frmVendorNew to edit the data:
Code:
Private Sub cmdEditVendor_Click()
On Error GoTo Err_cmdEditVendor_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmVendorNew"
    stLinkCriteria = "[CompanyID]=" & Me![cboCompanyName]

    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , "frmVendorManagement"
     
Exit_cmdEditVendor_Click:
   Exit Sub

Err_cmdEditVendor_Click:
   MsgBox Err.Description
   Resume Exit_cmdEditVendor_Click
End Sub

Why would the presence of or lack of data in the subform determine if the Vendor form opens correctly or not?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top