F
fordrules01
Hi,
I have a 2 forms. 1 called "company" and one called "centre". I have a
command button on the company form to open the centre form and filter for all
centres that are managed by the given company. Sounds simple enough but i'm
not having any luck with it so far.
Where the probem lies i think is that the primary fields of the 2 tables are
linked in a joining table "ManOrgAtCentre". I have the management
organisation appearing in the centre form in a subform. I have then created a
textbox to draw the companyID from the subform and put it into the main form
and that works fine. Where i run into trouble is that using the wizard in the
open form command it wont display the textbox control "ManCompanyID". As such
i tried to fix it up in VBA (where i am a total amateur) but can't get it
working. My code is below.
Private Sub CmdFilterCentreList_Click()
On Error GoTo Err_CmdFilterCentreList_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Centre"
stLinkCriteria = "[Forms].[Centre].[ManCompanyID]=" & "'" &
Me![CompanyID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CmdFilterCentreList_Click:
Exit Sub
Err_CmdFilterCentreList_Click:
MsgBox Err.Description
Resume Exit_CmdFilterCentreList_Click
End Sub
If anyone can find the problem in this please let me know.
I have a 2 forms. 1 called "company" and one called "centre". I have a
command button on the company form to open the centre form and filter for all
centres that are managed by the given company. Sounds simple enough but i'm
not having any luck with it so far.
Where the probem lies i think is that the primary fields of the 2 tables are
linked in a joining table "ManOrgAtCentre". I have the management
organisation appearing in the centre form in a subform. I have then created a
textbox to draw the companyID from the subform and put it into the main form
and that works fine. Where i run into trouble is that using the wizard in the
open form command it wont display the textbox control "ManCompanyID". As such
i tried to fix it up in VBA (where i am a total amateur) but can't get it
working. My code is below.
Private Sub CmdFilterCentreList_Click()
On Error GoTo Err_CmdFilterCentreList_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Centre"
stLinkCriteria = "[Forms].[Centre].[ManCompanyID]=" & "'" &
Me![CompanyID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CmdFilterCentreList_Click:
Exit Sub
Err_CmdFilterCentreList_Click:
MsgBox Err.Description
Resume Exit_CmdFilterCentreList_Click
End Sub
If anyone can find the problem in this please let me know.