|
|
Why won't my link criteria work?
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
|
|
0
|
|
|
|
Reply
|
Stapes
|
1/8/2008 11:02:54 AM |
|
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)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Stapes" <steve.staple@gmail.com> wrote in message
news:b32943da-3bb4-4d8a-ae67-195a6ce25b46@i29g2000prf.googlegroups.com...
> 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
|
|
0
|
|
|
|
Reply
|
Douglas
|
1/8/2008 11:53:54 AM
|
|
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] & """"
"Stapes" <steve.staple@gmail.com> wrote in message
news:b32943da-3bb4-4d8a-ae67-195a6ce25b46@i29g2000prf.googlegroups.com...
> 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
|
|
0
|
|
|
|
Reply
|
BruceM
|
1/8/2008 11:59:26 AM
|
|
|
2 Replies
173 Views
(page loaded in 0.064 seconds)
|
|
|
|
|
|
|
|
|