Why won't my link criteria work?

S

Stapes

Hi

I have the following code in my calling form:

Dim stDocName As String
Dim stLinkCriteria As String
If Not IsNull([Forms]![Old Contacts List].Form.[Combo43]) Then
stLinkCriteria = "FK_Type=" & [Forms]![Old Contacts List].Form.
[Combo43]
End If
stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Form1 uses datasheet view, and include the field FK_Type. However,
when I try to use this criteria, I get all the records. What am I
doing wrong?

Stapes
 
D

Douglas J. Steele

There's something wrong with your syntax. If you're trying to refer to a
control on a subform, it should be:

Forms![NameOfParentForm]![NameOfSubformControlOnParentForm].Form![NameOfControlOnSubform]

You appear to be missing either the name of the parent form, or the name of
the subform control on the parent form. (Remember that the name of the
subform control may be different than the name of the form being used as a
subform)
 
B

BruceM

Try:
If Not IsNull([Forms]![Old Contacts List]![Combo43]) Then
stLinkCriteria = "FK_Type=" & [Forms]![Old Contacts List]![Combo43]
etc.

This assumes the bound column in Combo43 is a number field. If it is text
you would need:
stLinkCriteria = "FK_Type=""" & [Forms]![Old Contacts List]![Combo43] & """"
 

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