I have 2 separate tables that need to be joined together. I'm trying to display certain fields from both tables by joining them with a matching field(same values but different column name) The user enters their employee id, then I need to return the other field values associated with that specific id# in a datagrid.
So far I'm able to return the other field values from one of my tables according to the id# entered. This is version1 of my query, which works
'my connection stuff is here rs.open "SELECT swpNum, swpInfo, swpType FROM tblSwipes WHERE (swpNum='"& sNum &"') and swpType=1 order by etc... set datagrid.datasource=rs
The datagrid displays the 3 fields associated with the #(sNum) entered by the user. But I'm having trouble when I try to rewrite the query to join tblSwipes with tblEmp to get fields returned from that table as well. Here's what I have for the new query
'connection stuff goes here rs.open "SELECT tblEmp.lastName,tblEmp.firstName, tblEmp.payNum, tblSwipes.swpNum, tblSwipes.swpType FROM tblEmp INNER JOIN tblSwipes ON tblEmp.payNum=tblSwipes.swpNum WHERE (swpNum='"& sNum &"') and swpType=1 order by etc... set datagrid.datasource =rs
Nothing is shown in the datagrid using this query so I'm guessing the problem is with my sql statement. any tips or suggestions on another way of doing this would be greatly appreciated.