Leo Coroneos
Leo Coroneos

Reputation: 7

MS Access 2016 - Opening report based on current record

I could do with some help with the final touches to my music store database, and it should come across as a very easy question to answer. My VBA programming primer book just arrived in the mail and I've searched the event procedure section for answers, as well as referring to these links:

https://msdn.microsoft.com/en-us/vba/access-vba/articles/docmd-openreport-method-access

https://bytes.com/topic/access/answers/690040-open-report-based-current-record

My problem here is as follows:

I'm trying to open a report in Access that only shows the data from one order when the Review button is pressed (see picture).

New Order form

Access is instead giving me the whole catalogue of orders (see picture).

Order report

This is no good, and it is occurring even after I implemented the following code:

VBA code - event procedure

I.e.

DoCmd.OpenReport "rptOrder", acViewPreview, , , , "OrderID = " & Me.OrderID

Can anyone help? What might I be doing wrong? Thanks in advance!

- LC

Upvotes: 0

Views: 1302

Answers (1)

tlemaster
tlemaster

Reputation: 859

The where clause should be in the 4th position.

DoCmd.OpenReport "rptOrder", acViewPreview, , "OrderID = " & Me.OrderID

Upvotes: 2

Related Questions