Click to See Complete Forum and Search --> : Data table relationship help


tekboy
01-17-2006, 09:00 PM
i have 2 tables create in access something like this but i having a problem the query record showup twice? any idea

TAble1

id (AutoNumber primary key )
zip
city
state
agentID(foreinger key)[/



Table2

agentID (primary key )
fname
lastname
email

NogDog
01-17-2006, 09:53 PM
Can you show us the query that is giving you the problem?

tekboy
01-18-2006, 12:06 AM
i think this one im not sure i have attached a zip file with all files, if you run it you will see it more cclear, the search was always showup as dublicate

If strSearch <> "" Then

' Build our query based on the input.
strSQL = "SELECT DISTINCT * " _
& "FROM zipcode, NotifyMapping " _
& "WHERE City LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "OR Zip LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "ORDER BY MktMgr;"

chazzy
01-18-2006, 11:08 AM
add in a where clause to join the two tables:

"AND zipcode.agentid = NotifyMapping.agentid "

tekboy
01-18-2006, 01:05 PM
hi thanks
i tried and
didnt work, was it because the way the data base relation to each other

or something else missing in my code

strSQL = "SELECT * " _
& "FROM zipcode, NotifyMapping " _
& "WHERE zipcode.MktID = NotifyMapping.MktID and City LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "OR Zip LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "ORDER BY MktMgr;"