Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Link Criteria to Sub Form

Status
Not open for further replies.

LarryDavidow

Technical User
Apr 22, 2002
56
US
Hi

I have a subform that is opened from a form that is linked via a keyed field.

I would like to link the subform with more than one field.

Here is my code for opening the subform so far.

Private Sub Company_DblClick(Cancel As Integer)
On Error GoTo Err_Company_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Bookings subform Detail"

stLinkCriteria = "[Company]=" & "'" & Me![Company] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Company_DblClick:
Exit Sub

Err_Company_DblClick:
MsgBox Err.Description
Resume Exit_Company_DblClick

End Sub

I would like to add another link value to the stLinkCriteria variable.
 
Maybe I should elaborate...

When I add the following,

im stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria1 As String

stDocName = "Bookings subform Detail"

stLinkCriteria = "[Company]=" & "'" & Me![Company] & "'"
stLinkCriteria1 = "[ModCode]=" & "'" & Me![Modcode] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria And stLinkCriteria1

I get a Type Mismatch error. There are a few other threads around where users have had the same problem, however, I can't find the mismatch in my data. If I take the "And" out, and just leave one of the link criteria, it works on either one - which means, there is no mismatch on my data. Are there any other requirements that I have not fulfilled???
 
Don't you love it when you fix your own stuff!!!

stLinkCriteria = "[Company]=" & "'" & Me![Company] & "'" & " and " & "[Modcode]=" & "'" & Me![Modcode] & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top