|
|
Hi everyone! Happy Thanksgiving! I'm using A02 on XP and I should know this by now but it's always just one little thing I miss. Darn it.
I have a record on my subform with a field [PlanNum] and a report with a query that contains the field [PlanNum]. On my subform, I have a button with the following OnClick:
DoCmd.RunCommand acCmdSaveRecord DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum DoCmd.RunCommand acCmdZoom100
What am I missing? I've played with the quotes and can't get it to work. When I click the button I get a parameter with my actual field value in it and asking me to fill it in. If I fill in the blank spot with GP0041, it works. I want it to open without having to satisfy the parameter, I could put that in the query criteria. If the form is open to GP0041, I want to view the report showing just that record.
Thank you in advance for your time and assistance. I would be lost without the newsgroups. -- Bonnie W. Anderson Cincinnati, OH
|
|
On Wed, 26 Nov 2008 05:56:05 -0800, Bonnie A wrote:
[Quoted Text] > Hi everyone! Happy Thanksgiving! I'm using A02 on XP and I should know > this by now but it's always just one little thing I miss. Darn it. > > I have a record on my subform with a field [PlanNum] and a report with a > query that contains the field [PlanNum]. On my subform, I have a button > with the following OnClick: > > DoCmd.RunCommand acCmdSaveRecord > DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum > DoCmd.RunCommand acCmdZoom100 > > What am I missing? I've played with the quotes and can't get it to > work. When I click the button I get a parameter with my actual field > value in it and asking me to fill it in. If I fill in the blank spot > with GP0041, it works. I want it to open without having to satisfy the > parameter, I could put that in the query criteria. If the form is open > to GP0041, I want to view the report showing just that record. > > Thank you in advance for your time and assistance. I would be lost > without the newsgroups.
I believe you need one more comma before your criteria. You are using the FILTER argument and you need to be using the WHERE argument.
-- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com
|
|
On Wed, 26 Nov 2008 05:56:05 -0800, Bonnie A <bonnielynnw[ at ]discussions.microsoft.com> wrote:
Since PlanNum is alphanumeric, it must be wrapped in singlequotes: DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]='" & Me.PlanNum & "'"
Put a breakpoint on that line, and ensure Me.PlanNum has the value you expect.
-Tom. Microsoft Access MVP
[Quoted Text] >DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum
|
|
"Bonnie A" <bonnielynnw[ at ]discussions.microsoft.com> wrote in message news:1CCB1BD3-5001-410A-8532-DD7A0B043B67[ at ]microsoft.com...
[Quoted Text] > Hi everyone! Happy Thanksgiving! I'm using A02 on XP and I should know > this > by now but it's always just one little thing I miss. Darn it. > > I have a record on my subform with a field [PlanNum] and a report with a > query that contains the field [PlanNum]. On my subform, I have a button > with > the following OnClick: > > DoCmd.RunCommand acCmdSaveRecord > DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum > DoCmd.RunCommand acCmdZoom100 > > What am I missing?
Because PlanNum is a text field, you need to embed quotes around the value. Assuming that it will never contain the single-quote character, try this:
DoCmd.OpenReport "rJanusLtr", acViewPreview, , _ "[PlanNum]='" & Me.PlanNum & "'"
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
Unless Access 2003 (which I have) is different from Access 2002 (which the OP has), the Filter argument would follow the first comma, and the Where argument the second comma, unless I am completely misreading something.
To the OP, is PlanNum a number field? If it is text you need: "[PlanNum] = """ & Me.PlanNum & """"
Expanded for clarity: "[PlanNum] = " " " & Me.PlanNum & " " " "
or: "[PlanNum] = ' " & Me.PlanNum & " ' "
For what exactly is the parameter prompt asking?
If no luck, another thing to try is to eliminate the Where condition, just to be sure the report opens properly. If you still receive the parameter prompt with no Where condition, go back to the report's Record Source query (if it is using a query), or check the Sorting and Grouping.
"Rick Brandt" <rickbrandt2[ at ]hotmail.com> wrote in message news:rTcXk.9141$YU2.8501[ at ]nlpi066.nbdc.sbc.com...
[Quoted Text] > On Wed, 26 Nov 2008 05:56:05 -0800, Bonnie A wrote: > >> Hi everyone! Happy Thanksgiving! I'm using A02 on XP and I should know >> this by now but it's always just one little thing I miss. Darn it. >> >> I have a record on my subform with a field [PlanNum] and a report with a >> query that contains the field [PlanNum]. On my subform, I have a button >> with the following OnClick: >> >> DoCmd.RunCommand acCmdSaveRecord >> DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum >> DoCmd.RunCommand acCmdZoom100 >> >> What am I missing? I've played with the quotes and can't get it to >> work. When I click the button I get a parameter with my actual field >> value in it and asking me to fill it in. If I fill in the blank spot >> with GP0041, it works. I want it to open without having to satisfy the >> parameter, I could put that in the query criteria. If the form is open >> to GP0041, I want to view the report showing just that record. >> >> Thank you in advance for your time and assistance. I would be lost >> without the newsgroups. > > I believe you need one more comma before your criteria. You are using > the FILTER argument and you need to be using the WHERE argument. > > > -- > Rick Brandt, Microsoft Access MVP > Email (as appropriate) to... > RBrandt at Hunter dot com
|
|
Thank you, thank you, thank you!!!
That one ALWAYS gets me.
Your time was truly appreciated! -- Bonnie W. Anderson Cincinnati, OH
"Tom van Stiphout" wrote:
[Quoted Text] > On Wed, 26 Nov 2008 05:56:05 -0800, Bonnie A > <bonnielynnw[ at ]discussions.microsoft.com> wrote: > > Since PlanNum is alphanumeric, it must be wrapped in singlequotes: > DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]='" & > Me.PlanNum & "'" > > Put a breakpoint on that line, and ensure Me.PlanNum has the value you > expect. > > -Tom. > Microsoft Access MVP > > > >DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum >
|
|
Hi Dirk,
I truly appreciate the time you put in to help others.
Thank you, it's perfect! -- Bonnie W. Anderson Cincinnati, OH
"Dirk Goldgar" wrote:
[Quoted Text] > "Bonnie A" <bonnielynnw[ at ]discussions.microsoft.com> wrote in message > news:1CCB1BD3-5001-410A-8532-DD7A0B043B67[ at ]microsoft.com... > > Hi everyone! Happy Thanksgiving! I'm using A02 on XP and I should know > > this > > by now but it's always just one little thing I miss. Darn it. > > > > I have a record on my subform with a field [PlanNum] and a report with a > > query that contains the field [PlanNum]. On my subform, I have a button > > with > > the following OnClick: > > > > DoCmd.RunCommand acCmdSaveRecord > > DoCmd.OpenReport "rJanusLtr", acViewPreview, , "[PlanNum]=" & Me.PlanNum > > DoCmd.RunCommand acCmdZoom100 > > > > What am I missing? > > Because PlanNum is a text field, you need to embed quotes around the value. > Assuming that it will never contain the single-quote character, try this: > > DoCmd.OpenReport "rJanusLtr", acViewPreview, , _ > "[PlanNum]='" & Me.PlanNum & "'" > > > -- > Dirk Goldgar, MS Access MVP > www.datagnostics.com > > (please reply to the newsgroup) > >
|
|
|