Open alternate form with criteria

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
 
M

Marshall Barton

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top