Report button linked to exact report record- Open report method?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Cheryl
I am not sure I understand so let me explain my train of thought

First, the field that links all of the different tables and uniquelly identifies my record is the "ID" field. So, in the code that you gave me I would Replace "CustID" with "ID". What I dont udnerstand is where to place this code. I have a button (that i created with a wizard) on my "Destruction Request" form that opens my "Destruction Request" Report. When i click on the properties for the button I do not see a OpenReport option. Do you mean to place it on the On click option

I am confused.
I really appreciate your help, thank
-Ric

----- Cheryl Fischer wrote: ----

Rich

You will need to add a Where Condition to the OpenReport method so that th
report shows only the information for the record displayed on your form. Fo
example, if the field on your form that uniquely identifies the record i
CustID, you could use it to determine the where condition as follows

Dim strCriteria As Strin

' This works when your CustID field is tex
strCriteria = "[CustID] = " & Chr(34) & Me!CustID & Chr(34
DoCmd.OpenReport "MyReport", acViewPreview, , strCriteri

' This works when your CustID field is a numbe
strCriteria = "[CustID] = " & Me!CustI
DoCmd.OpenReport "MyReport", acViewPreview, , strCriteri


-

Cheryl Fischer, MVP Microsoft Acces



Rich said:
Hi
I have created a form that, ultimately, fills out a form that I use on
regular basis. I have created a report preview button, but when I click it
it always goes to the first record in the series of reports. What I woul
like to accomplish is that if I am in the form on record #5 that when
click the Report Preview button that it goes to the correspondin
report(#5)
 
Response is in your 10:06 am post

--

Cheryl Fischer, MVP Microsoft Access



Rich said:
Cheryl,
I am not sure I understand so let me explain my train of thought.

First, the field that links all of the different tables and uniquelly
identifies my record is the "ID" field. So, in the code that you gave me I
would Replace "CustID" with "ID". What I dont udnerstand is where to place
this code. I have a button (that i created with a wizard) on my "Destruction
Request" form that opens my "Destruction Request" Report. When i click on
the properties for the button I do not see a OpenReport option. Do you mean
to place it on the On click option?
I am confused..
I really appreciate your help, thanks
-Rich

----- Cheryl Fischer wrote: -----

Rich,

You will need to add a Where Condition to the OpenReport method so that the
report shows only the information for the record displayed on your form. For
example, if the field on your form that uniquely identifies the record is
CustID, you could use it to determine the where condition as follows:

Dim strCriteria As String

' This works when your CustID field is text
strCriteria = "[CustID] = " & Chr(34) & Me!CustID & Chr(34)
DoCmd.OpenReport "MyReport", acViewPreview, , strCriteria

' This works when your CustID field is a number
strCriteria = "[CustID] = " & Me!CustID
DoCmd.OpenReport "MyReport", acViewPreview, , strCriteria


--

Cheryl Fischer, MVP Microsoft Access



Rich said:
Hi,
I have created a form that, ultimately, fills out a form that I use
on a
regular basis. I have created a report preview button, but when I click it,
it always goes to the first record in the series of reports. What I would
like to accomplish is that if I am in the form on record #5 that when I
click the Report Preview button that it goes to the corresponding
report(#5).
Thanks in advance
-Rich
 
Back
Top