A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

WhereCondition



 
 
Thread Tools Display Modes
  #1  
Old August 18th, 2004, 08:05 PM
Ed the Redhead
external usenet poster
 
Posts: n/a
Default WhereCondition

I have this statement in a VBA code and it is not working. Can anyone
provide assistance. Thanks.

DoCmd.OpenReport "rptBillingStatement", acViewPreview, , "agNumber = " &
Me.[txtAgencyNo]

The problem lies with the WhereCondition Statement. I have never used this
before and I'm having problems getting it to work.

agNumber=Agent Number on the report
txtAgencyNo = Agent Number on the form, which they enter before pressing a
"View Report" Command button

Thanks.
  #2  
Old August 18th, 2004, 09:29 PM
fredg
external usenet poster
 
Posts: n/a
Default

On Wed, 18 Aug 2004 12:05:03 -0700, Ed the Redhead wrote:

I have this statement in a VBA code and it is not working. Can anyone
provide assistance. Thanks.

DoCmd.OpenReport "rptBillingStatement", acViewPreview, , "agNumber = " &
Me.[txtAgencyNo]

The problem lies with the WhereCondition Statement. I have never used this
before and I'm having problems getting it to work.

agNumber=Agent Number on the report
txtAgencyNo = Agent Number on the form, which they enter before pressing a
"View Report" Command button

Thanks.


The code is OK IF... agNumber is a Number datatype.
However, if agNumber is a Text datatype then use:
DoCmd.OpenReport "rptBillingStatement", acViewPreview, , "agNumber =
'" & Me![txtAgencyNo] & "'"
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
  #3  
Old August 18th, 2004, 10:40 PM
Reggie
external usenet poster
 
Posts: n/a
Default

Ed, Change your Where statement as follows and make sure that you do
have a control on your report named [agNumber].

If agNumber is a number:
"[agNumber] =" & Me.[txtAgencyNo]

If agNumber is a text field:
"[agNumber] ='" & Me.[txtAgencyNo] & "'"

If agNumber is a date field (which I doubt):
"[agNumber] =#" & Me.[txtAgencyNo] & "#"

Hope this helps!

Reggie

Ed the Redhead wrote:
I have this statement in a VBA code and it is not working. Can anyone
provide assistance. Thanks.

DoCmd.OpenReport "rptBillingStatement", acViewPreview, , "agNumber = " &
Me.[txtAgencyNo]

The problem lies with the WhereCondition Statement. I have never used this
before and I'm having problems getting it to work.

agNumber=Agent Number on the report
txtAgencyNo = Agent Number on the form, which they enter before pressing a
"View Report" Command button

Thanks.

  #4  
Old August 19th, 2004, 12:41 PM
Ed the Redhead
external usenet poster
 
Posts: n/a
Default

Thank you so much. It works now. This was the last thing I needed to put
this project to bed!

"Reggie" wrote:

Ed, Change your Where statement as follows and make sure that you do
have a control on your report named [agNumber].

If agNumber is a number:
"[agNumber] =" & Me.[txtAgencyNo]

If agNumber is a text field:
"[agNumber] ='" & Me.[txtAgencyNo] & "'"

If agNumber is a date field (which I doubt):
"[agNumber] =#" & Me.[txtAgencyNo] & "#"

Hope this helps!

Reggie

Ed the Redhead wrote:
I have this statement in a VBA code and it is not working. Can anyone
provide assistance. Thanks.

DoCmd.OpenReport "rptBillingStatement", acViewPreview, , "agNumber = " &
Me.[txtAgencyNo]

The problem lies with the WhereCondition Statement. I have never used this
before and I'm having problems getting it to work.

agNumber=Agent Number on the report
txtAgencyNo = Agent Number on the form, which they enter before pressing a
"View Report" Command button

Thanks.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WhereCondition ignored when MS Access Form invokes Report yisraelharris Using Forms 1 June 1st, 2004 01:24 PM


All times are GMT +1. The time now is 03:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.