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

Report View (Dynamic View)

P: 54
I have a form that calls and generate a dynamic report

In that form i have a textbox and a commandbutton

In my textbox i enter an ID Formatted like this ('POC-00001')
and then i click the command button to preview the
report of that certain id and then print the report

But the problem is if i enter another id in my textbox like ('POC-00002')
and click the command button
the report show and still the POC-00001 report
Can anybody help me for my script

This is my code
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmdopenreport_Click()
  4. On Error GoTo Err_cmdopenreport_Click
  5. Dim limit As String
  6. limit = "id = " & InputPCnum.Value
  7.    Dim stDocName As String
  8.  
  9.     stDocName = "jointable"
  10.     DoCmd.OpenReport stDocName, acPreview, limit
  11.  
  12. Exit_cmdopenreport_Click:
  13.     Exit Sub
  14.  
  15. Err_cmdopenreport_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_cmdopenreport_Click
  18.  
  19. End Sub
  20.  
-cmdopenreport- Commandbutton Name
-InputPCnum - textbox name
-joint table - reportname
Mar 12 '07 #1
Share this Question
Share on Google+
12 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
You were opening the report with a filter instead of a where condition. Just add another comma before the limit and it should work fine.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmdopenreport_Click()
  4. On Error GoTo Err_cmdopenreport_Click
  5. Dim limit As String
  6.    Dim stDocName As String
  7.  
  8.    limit = "[id] = " & Me.InputPCnum
  9.    stDocName = "jointable"
  10.    DoCmd.OpenReport stDocName, acPreview, , limit
  11.  
  12. Exit_cmdopenreport_Click:
  13.     Exit Sub
  14.  
  15. Err_cmdopenreport_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_cmdopenreport_Click
  18.  
  19. End Sub
  20.  

Mary
Mar 12 '07 #2

P: 54
Ok MAry il try for that thanks
Mar 13 '07 #3

P: 54
i add a comma now

Private Sub cmdopenreport_Click()
On Error GoTo Err_cmdopenreport_Click
Dim limit As String
limit = "id = " & InputPCnum.Value
Dim stDocName As String

stDocName = "jointable"
DoCmd.OpenReport stDocName, acPreview, , limit

Exit_cmdopenreport_Click:
Exit Sub

Err_cmdopenreport_Click:
MsgBox Err.Description
Resume Exit_cmdopenreport_Click

End Sub

but everytime i input a certain ID theres a form popping up saying "Enter PArameter Value" and if i put any numeric value in that my report view will show but no data i mean its blank report...
Mar 13 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
change this
Expand|Select|Wrap|Line Numbers
  1. limit = "id = " & InputPCnum.Value
  2.  
to
Expand|Select|Wrap|Line Numbers
  1. limit = "id = " & Me.InputPCnum
  2. Msgbox limit
  3.  
See what pops up in the message box. Is it what you expect. If it is, is it a string by any chance?

Mary
Mar 13 '07 #5

P: 54
I change the code, Now everytime i enter the ID theres a new window popping up says "Microsoft Office Access" id= POC - 00001 then a command button (OK) then if i click ok the window popup again for "enter parameter value" then if i enter again the ID the report is still blank,

The Nature of my ID in Header Table is Autonumber with Formatted of \P\C\ - 00000 then it has a link to my Detail Table which is my ID is a Number formatted same as in my Header Table
Mar 13 '07 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
I change the code, Now everytime i enter the ID theres a new window popping up says "Microsoft Office Access" id= POC - 00001 then a command button (OK) then if i click ok the window popup again for "enter parameter value" then if i enter again the ID the report is still blank,

The Nature of my ID in Header Table is Autonumber with Formatted of \P\C\ - 00000 then it has a link to my Detail Table which is my ID is a Number formatted same as in my Header Table
Your problem is that user is entering POC - which is formatted but not stored so you can't pass it through as a value. Assuming there are always five numbers then change the code as follows:

Expand|Select|Wrap|Line Numbers
  1. limit = "[id]=" & CLng(Right(Me.InputPCnum, 5))
  2.  
and remove the "Msgbox limit" line.

Mary
Mar 13 '07 #7

P: 54
Ok it works now thank you very very much...Il Study more in programming Access!
Mar 13 '07 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
Ok it works now thank you very very much...Il Study more in programming Access!
No problem. Glad you got it working.

Mary
Mar 13 '07 #9

P: 54
can u please help me in my other problem no one was replying in my post, : (
the topic is Transfering data from form to a new blank form..? or Importing data to a new form
Mar 13 '07 #10

NeoPa
Expert Mod 15k+
P: 31,347
If you want to draw attention to another thread you'll have to post a link, otherwise how can anyone find the one you want them to help with.

MODERATOR.
Mar 13 '07 #11

P: 54
ok im sorry
Mar 14 '07 #12

NeoPa
Expert Mod 15k+
P: 31,347
Not a problem. Do you need help posting a link?
Mar 14 '07 #13

Post your reply

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