By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,390 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,390 IT Pros & Developers. It's quick & easy.

Report Problem

manoj9849967222
P: 48
Hi all

I have a form named "Form1" which has two textboxes "Textbox1" & Textbox3" which is ment to enter dates & also a command button "command9"

I have a report named "Report1" which is based on query. The query is working fine.

what i want to do is when the command button is click i want to load the report between the two given dates in the "textbox1" & "Textbox3"

I have tried but is not working. I have used the following codes

Private Sub Command9_Click()
Dim stDocName
Dim stLinkCriteria
stDocName = "Report1"
DoCmd.OpenReport stDocName, , , stLinkCriteria
End Sub

I hope i am missing something in the codes.

Please help me out

Regards
Manoj.
Sep 11 '07 #1
Share this Question
Share on Google+
5 Replies


P: 48
Hey, I have the same problem. However an easy exit is to do a query.

You create a query with all the fields and on the Date field Type the code below.

Between [Enter First Date ] And [Enter Last Date]

Then you create a report based on the query that you just created. When someone clicks the report they should be able to enter the 2 dates and the report should be created.

Hope this helps.
Sep 11 '07 #2

P: 26
You could go the query route, but the missing item in your code is the definition of your stLinkCriteria similar to how you have stDocName="Report1". You need to define this.
Sep 11 '07 #3

Jim Doherty
Expert 100+
P: 897
Hi all

I have a form named "Form1" which has two textboxes "Textbox1" & Textbox3" which is ment to enter dates & also a command button "command9"

I have a report named "Report1" which is based on query. The query is working fine.

what i want to do is when the command button is click i want to load the report between the two given dates in the "textbox1" & "Textbox3"

I have tried but is not working. I have used the following codes

Private Sub Command9_Click()
Dim stDocName
Dim stLinkCriteria
stDocName = "Report1"
DoCmd.OpenReport stDocName, , , stLinkCriteria
End Sub

I hope i am missing something in the codes.

Please help me out

Regards
Manoj.

You need to create the criteria string for the where clause argument for your report the dates of which are passed to the variable strLinkCriteria and formatted accordingly by the function FORMAT

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim stDocName
  3. Dim stLinkCriteria
  4. strLinkCriteria = "#[NameOfYourField] Between #" & Format(Me!TextBox1, "mm/dd/yyyy")
  5. strLinkCriteria = strLinkCriteria & "# and #" & Format(Me!TextBox3, "mm/dd/yyyy") & "#"
  6. stDocName = "Report1"
  7. DoCmd.OpenReport stDocName, , , stLinkCriteria
  8.  
  9.  

Regards

Jim
Sep 12 '07 #4

manoj9849967222
P: 48
Hi Jim

I am not able to view the report. It is directly going to the printer.

Regards
Manoj
Sep 12 '07 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Jim

I am not able to view the report. It is directly going to the printer.

Regards
Manoj
Hi Manoj

Change line 6 as follows:

DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
Sep 13 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.