Multiple Link Criteria

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

Could anyone help me with the following code? I have one
form when the user can choose from a list of
organizations and then click a button which executes the
following code. The second form which should be opening
should look for the given organization in
field 'organization 1', 'organization 2' or 'organization
3'. No matter what, I get the results only for the org 1
field... never the others. Can't find my problem. I've
checked spelling and such... any ideas?



Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteriaPt1 As String
Dim stLinkCriteriaPt2 As String
Dim stLinkCriteriaPt3 As String

stDocName = "Contacts"

stLinkCriteriaPt1 = "[Organization 1]=" & "'" & Me!
[Organization] & "'"
stLinkCriteriaPt2 = "[Organization 2]=" & "'" & Me!
[Organization] & "'"
stLinkCriteriaPt3 = "[Organization 3]=" & "'" & Me!
[Organization] & "'"
stLinkCriteria = stLinkCriteriaPt1 & " OR " &
stLinkCriteriaPt2 & " OR " & stLinkCriteriaPt3

DoCmd.OpenForm stDocName, , , stLinkCriteria
 
---------- "Emma said:
Could anyone help me with the following code? I have one
form when the user can choose from a list of
organizations and then click a button which executes the
following code. The second form which should be opening
should look for the given organization in
field 'organization 1', 'organization 2' or 'organization
3'. No matter what, I get the results only for the org 1
field... never the others. Can't find my problem. I've
checked spelling and such... any ideas?

Emma,

your table design is not the best. You're storing information in field
names, and this is a big NO-NO. Have you thought about what happens if
there are going to be more organisations? You would have then to
rework the application. You don't give more info about the tables, but
I would guess the organisations should be stored in a detail table
related to the existing one in a 1:N relation (i.e. 1 record in the
existing table can have several detail records storing the
organisations belonging to it).

This said, did you check the RecordSource of the Contacts form? It
must return all 3 organisation fields, otherwise the criterias for
organisation 2 and 3 have no effect.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Back
Top