Learner Simple Report Programming

  • Thread starter NG Tian via AccessMonster.com
  • Start date
N

NG Tian via AccessMonster.com

Recently i was making a form in access 2002. How i am going to preview the
report based on one of field, criteria in form with a click of a button. For
etc, In "Job Details" form, a result is display in form, then i click a
button to preview the report based on job number whatever it is being shown
in form. Note, each job number have few records. txtJOBNO is a name of field.

The code:

Private Sub cmdjobdetail_Click()
On Error GoTo Err_cmdjobdetail_Click

Dim stDocName As String

stDocName = "Job Details"
stLinkCriteria = "[JOB NO]= " & Me.txtJOBNO
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Exit_cmdjobdetail_Click:
Exit Sub

Err_cmdjobdetail_Click:
MsgBox Err.Description


But my code does not work. T_T ....
 
R

Rick Brandt

NG said:
Recently i was making a form in access 2002. How i am going to
preview the report based on one of field, criteria in form with a
click of a button. For etc, In "Job Details" form, a result is
display in form, then i click a button to preview the report based on
job number whatever it is being shown in form. Note, each job number
have few records. txtJOBNO is a name of field.

The code:

Private Sub cmdjobdetail_Click()
On Error GoTo Err_cmdjobdetail_Click

Dim stDocName As String

stDocName = "Job Details"
stLinkCriteria = "[JOB NO]= " & Me.txtJOBNO
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Exit_cmdjobdetail_Click:
Exit Sub

Err_cmdjobdetail_Click:
MsgBox Err.Description


But my code does not work. T_T ....

It looks good to me providing that [JOB NO] is a Numeric field and not a Text
field. If it's actually Text then you need quotes around the criteria value.
 
N

NG Tian via AccessMonster.com

Do enlightening me

yes it is text field because of it " 05/001 " how i going to put quotes?

like this

stLinkCriteria = "[JOB NO]= " & Me.txtJOBNO & "'" ?


Rick said:
Recently i was making a form in access 2002. How i am going to
preview the report based on one of field, criteria in form with a
[quoted text clipped - 21 lines]
But my code does not work. T_T ....

It looks good to me providing that [JOB NO] is a Numeric field and not a Text
field. If it's actually Text then you need quotes around the criteria value.
 
N

NG Tian via AccessMonster.com

i have tried that code. it return nothing in preview report instead.

something wrong ?

NG said:
Do enlightening me

yes it is text field because of it " 05/001 " how i going to put quotes?

like this

stLinkCriteria = "[JOB NO]= " & Me.txtJOBNO & "'" ?
[quoted text clipped - 4 lines]
It looks good to me providing that [JOB NO] is a Numeric field and not a Text
field. If it's actually Text then you need quotes around the criteria value.
 
R

Rick Brandt

NG said:
Do enlightening me

yes it is text field because of it " 05/001 " how i going to put
quotes?

like this

stLinkCriteria = "[JOB NO]= " & Me.txtJOBNO & "'" ?

stLinkCriteria = "[JOB NO]= ' " & Me.txtJOBNO & " ' "

I added spaces to make the single quotes stand out in this post. You would omit
those in your actual code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top