Hi. I'm a newbie. I'm stuck and would really appreciate your help. I have searched Google, this forum and others. I have found codes and tips for similar problems and have tried applying many of them but to no avail (?!). Here's the rundown.
I am on Access 2000 on XP -
Form 1: frmCompany (incl subfrmAddress, lstContacts and other info)
Form 2: frmContacts (incl cboCompanyID and other info)
cboCompanyID rowsource data is:
SELECT [tblCompany].[CompanyID], [tblCompany].[CoName], [tblAddress].[AddressID], [tblAddress].[CityTown], [tblAddress].[Country], [tblCompany].[DialPrefix] FROM tblCompany INNER JOIN tblAddress ON [tblCompany].[CompanyID]=[tblAddress].[CompanyID];
Note that only [tblCompany].[CoName] , [tblAddress].[CityTown], [tblAddress].[Country] is displayed in the combobox. This is because many of the companies have offices in various locations around the world. Each office location is treated as a different and separate company although they have the same name.
WHAT I'M TRYING TO ACHIEVE
From the frmCompany click a button to open a blank frmContacts and automatically select and fill cboCompany.
The frmContacts opens, but does not populate cboCompanyID (I am expecting the number of Company records to be around a thousand thus prefer to open frmContacts from frmCompany and auto-fill the cboCompanyID).
Here is where i'm up to now... and it doesn't work!:
Private Sub AddNewPerson_Click()
On Error GoTo Err_AddNewPerson_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmContacts"
stLinkCriteria = "[cboCompanyID] =" & Me.txtCompanyID
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Exit_AddNewPerson_Click:
Exit Sub
Err_AddNewPerson_Click:
MsgBox Err.Description
Resume Exit_AddNewPerson_Click
End Sub
Can anyone please help?
I am on Access 2000 on XP -
Form 1: frmCompany (incl subfrmAddress, lstContacts and other info)
Form 2: frmContacts (incl cboCompanyID and other info)
cboCompanyID rowsource data is:
SELECT [tblCompany].[CompanyID], [tblCompany].[CoName], [tblAddress].[AddressID], [tblAddress].[CityTown], [tblAddress].[Country], [tblCompany].[DialPrefix] FROM tblCompany INNER JOIN tblAddress ON [tblCompany].[CompanyID]=[tblAddress].[CompanyID];
Note that only [tblCompany].[CoName] , [tblAddress].[CityTown], [tblAddress].[Country] is displayed in the combobox. This is because many of the companies have offices in various locations around the world. Each office location is treated as a different and separate company although they have the same name.
WHAT I'M TRYING TO ACHIEVE
From the frmCompany click a button to open a blank frmContacts and automatically select and fill cboCompany.
The frmContacts opens, but does not populate cboCompanyID (I am expecting the number of Company records to be around a thousand thus prefer to open frmContacts from frmCompany and auto-fill the cboCompanyID).
Here is where i'm up to now... and it doesn't work!:
Private Sub AddNewPerson_Click()
On Error GoTo Err_AddNewPerson_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmContacts"
stLinkCriteria = "[cboCompanyID] =" & Me.txtCompanyID
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Exit_AddNewPerson_Click:
Exit Sub
Err_AddNewPerson_Click:
MsgBox Err.Description
Resume Exit_AddNewPerson_Click
End Sub
Can anyone please help?