C
cableguy47905 via AccessMonster.com
I have a main form that I need to be able to open another form that is based
on two different fields on the main form.
This is what I have:
Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "SFRM_AllLocationsperContract"
stLinkCriteria = (((TBL_LocationContract.ContractNumber) = "&[Forms]!
[FRM_CompanyAddContracts]![txtContractID]&") And ((TBL_LocationContract.
CompanyID) = "&[Forms]![FRM_CompanyAddContracts]![txtCompanyID]&"))
DoCmd.OpenForm stDocName, , , WhereCondition:=stLinkCriteria
Exit_cmdOpenForm_Click:
Exit Sub
Err_cmdOpenForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenForm_Click
End Sub
I get the error that "Object is required"
I got the criteria from opening up the query and entering in the two fields
that are needed into the criteria. Then opened the query in SQL view and
copied that into the code. I know the syntax is off, but I can't seem to get
a good result.
I have also tried to put in :
stLinkCriteria = (("[ContractNumber] = &[Forms]![FRM_CompanyAddContracts]!
[txtContractID]&") And ("[CompanyID] = " & [Forms]![FRM_CompanyAddContracts]!
[txtCompanyID]))
into the stLinkCriteria, but then i get type mismatch. The ContractNumber is
text and CompanyID is a number.
Can someone help with this?
on two different fields on the main form.
This is what I have:
Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "SFRM_AllLocationsperContract"
stLinkCriteria = (((TBL_LocationContract.ContractNumber) = "&[Forms]!
[FRM_CompanyAddContracts]![txtContractID]&") And ((TBL_LocationContract.
CompanyID) = "&[Forms]![FRM_CompanyAddContracts]![txtCompanyID]&"))
DoCmd.OpenForm stDocName, , , WhereCondition:=stLinkCriteria
Exit_cmdOpenForm_Click:
Exit Sub
Err_cmdOpenForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenForm_Click
End Sub
I get the error that "Object is required"
I got the criteria from opening up the query and entering in the two fields
that are needed into the criteria. Then opened the query in SQL view and
copied that into the code. I know the syntax is off, but I can't seem to get
a good result.
I have also tried to put in :
stLinkCriteria = (("[ContractNumber] = &[Forms]![FRM_CompanyAddContracts]!
[txtContractID]&") And ("[CompanyID] = " & [Forms]![FRM_CompanyAddContracts]!
[txtCompanyID]))
into the stLinkCriteria, but then i get type mismatch. The ContractNumber is
text and CompanyID is a number.
Can someone help with this?