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

How to connect two tables in query

Status
Not open for further replies.

Mackooo

MIS
Nov 17, 2005
18
US
Hi again,

I am having problem in opening a form and with following query,as I have inner joint in the query and try to open thin thing with a code on click with a button. the filtering is done with item_number on the current form on as I have two tables connected in querry and both have item_number in it and it gives me an error. code is shown below.


Dim strReportName As String
Dim strCriteria As String
strReportName = "rptitems"
strCriteria = "items_log.[items_number]='" & Me![items_number] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub

Please help to modify this code to refer to aaprticular table.


SELECT items.item_number, item.[Items_Description]
FROM items INNER JOIN items_Log ON items.[item_number] = items_Log.[items_number];


Thanks,

 
There is no reason to provide the table name in the where clause since your query only returns one column named Item_Number.

Code:
Dim strReportName As String
Dim strCriteria As String
       strReportName = "rptitems"
       strCriteria = "[items_number]='" & Me![items_number] & "'"
       DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top