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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OR Statement inside Link Child and Master Fields

Status
Not open for further replies.

MrBanks

Programmer
Jun 23, 2011
2
CA
I'm creating a database and I would like to include an OR statement in the field linking.
I have two fields that work together as being unique, so the AND (read: semicolon) works great in that sense. I would also like to include records that match another field aswell.
I successfully did this using QBF with a stored procedure, however I was unable to insert new records.

Table Layouts:
Cable Records: Cable, Pair, ..., Local, ...
SR/TT Junction: SR/TT, ..., Cable, Pair, Local, ...
SR/TT: SR/TT, Time, Date, Remarks, Pers

I have SR/TT and SR/TT Junction joined in the subform and am looking to link the (Cable and Pair) or Local fields with Cable Records to eliminate the need for a form to show each field link.

I am using a datasheet and it won't let me use multiple subforms.

Using:
MS ACCESS 2003
MS SQL Server 2000

Has anyone done something similar to this?

Thanks,

Banks.
 
try this

use this stored procedure for the subform


Create procedure spname

@prram1 type,
@pram2 type,
@pram3 type
As


Select field1,field2
from tablename
where field1=@prram1
And field2=@prram2
union
select
Select field1,field2
from tablename
where pram3=fieldxx


return


and in the InputParameters of the subform
@prram1 type=forms!formname!controlname,
@pram2 type=forms!formname!controlname,
@pram3 type=forms!formname!controlname
you might need a requery on the on current of the main form





return
 
Yes, a stored procedure will retreive records, however I am unable to insert new records through a stored procedure.
 
if yo change the SP from a union to an or does it help

Create procedure spname

@prram1 type,
@pram2 type,
@pram3 type
As


Select field1,field2
from tablename
where (field1=@prram1 And field2=@prram2)
or (pram3=fieldxx)


return

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top