Open alternate form with criteria

  • Thread starter Thread starter MikeF
  • Start date Start date
M

MikeF

The following code on a button in frmMaster will open the Companies form,
filtering all records to CompanyID in the current record.

There are multiple records that contain the same CompanyID, but some don't
have anything in the "DetailID" field.
Need the following code to filter as such.

In short, the Companies form needs to be filtered on all records where
CompanyID is the same as the current record *and* DetailID IsNull.

Have implanted a placeholder line where I think its proper syntax should go
....
*** WHERE FIELD “DetailID" Is Null ***
.... Objective is to find that syntax.

Any assistance is greatly appreciated.
Regards,
- Mike




Private Sub btnFrmCompany_Click()
On Error GoTo Err_btnFrmCompany_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCompanies"

stLinkCriteria = "[CompanyID]=" & Me![CompanyID]
*** WHERE FIELD “address†Is Null ***
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_btnFrmCompany_Click:
Exit Sub

Err_btnFrmCompany_Click:
MsgBox Err.Description
Resume Exit_btnFrmCompany_Click

End Sub
 
MikeF said:
The following code on a button in frmMaster will open the Companies form,
filtering all records to CompanyID in the current record.

There are multiple records that contain the same CompanyID, but some don't
have anything in the "DetailID" field.
Need the following code to filter as such.

In short, the Companies form needs to be filtered on all records where
CompanyID is the same as the current record *and* DetailID IsNull.

You were very close:

stLinkCriteria = "CompanyID=" & Me!CompanyID _
& " And DetailID Is Null"
 
Back
Top