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

Trying to link a report line to the corresponding table record 1

Status
Not open for further replies.

pmonett

Programmer
Sep 5, 2002
2,632
FR
Greetings,

Newcomer to Access in general, I'm trying to build a report that will allow the user to click on a line index key and open a Form that shows that table line.

Specifically, let's say that I have a table called Product Lines. That table contains all products produced and one of the fields is the Product Line. A given Product Line can, obviously, contain one or more products. It's a classification thing.

Of course, I have a PLine form to allow users to easily check/modify the data in that table.

Now, I have been asked to allow users to view only products within a Product Line. Fine, there's a Report for that - except that they want to be able to click on a line of the report and have the corresponding PLine open.

I have found the OnClick event of the ID field in the report, and I have built a macro that opens the PLine form on condition = [ID], but if the form does open, it always shows the first record.

I'm sure I've done something wrong. Could someone point me in the right direction ?

Thanks in advance,

Pascal.

I've got nothing to hide, and I demand that you justify what right you have to ask.
 
often when you execute a openform or openreport method with a criteria and it goes to the first record the problem is with the criteria. There is something in the criteria not written correctly so that it cannot find what you are looking for and it goes to the first record as a default.

To check I often do it in two parts so that I can see the criteria

Code:
dim  Criteria as string
criteria = "EmployeeID = " & me.ID
debug.print criteria ' check that it looks good
DoCmd.OpenForm "Employees", , ,Criteria

Remember if the value is text
Code:
criteria = "LastName = '" & me.LastName & "'"
 
Thank you very much !
I removed my flawed macro and used your code instead (adapting it to my table, of course) and it works flawlessly.
I'll be using that again !

Pascal.

I've got nothing to hide, and I demand that you justify what right you have to ask.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top