Continuous form preview button

  • Thread starter ColeVet67 via AccessMonster.com
  • Start date
C

ColeVet67 via AccessMonster.com

I have a DB continuous form with a button to display a form in print preview.
I need this button to only display the 1 form i am working with. If i press
the button all of the forms are available for print preview. They are listed
by JCN in the continuous form.

here is the code:

Private Sub Job_Details_BTn_Click()
On Error GoTo Err_Job_Details_BTn_Click

Dim stDocName As String
Dim Job_Control_Number As String
stDocName = "Open Status Board report by JCN"
DoCmd.OpenReport stDocName, acPreview, Job_Control_Number

Exit_Job_Details_BTn_Click:
Exit Sub

Err_Job_Details_BTn_Click:
MsgBox Err.Description
Resume Exit_Job_Details_BTn_Click

End Sub

Any help would be great
 
F

fredg

See comments in line....
I have a DB continuous form with a button to display a form in print preview.
I need this button to only display the 1 form i am working with. If i press
the button all of the forms are available for print preview. They are listed
by JCN in the continuous form.
I would suggest you make a point of using the correct terminology when
asking for technical help. It makes it easier for us to help you.
You have one "form" (the continuous form) which is displaying many
"records". I suspect you wish to preview a "report" (a different
object) based upon just the one record that has the focus on your
continuous form.
here is the code:

Private Sub Job_Details_BTn_Click()
On Error GoTo Err_Job_Details_BTn_Click

Dim stDocName As String
Dim Job_Control_Number As String

Where below do you give a value to Job_Control_Number?
i.e. [Job_Control_Number] = ?
stDocName = "Open Status Board report by JCN"
DoCmd.OpenReport stDocName, acPreview, Job_Control_Number

Even if you had given Job_Control_Number a value, you have placed the
argument in the wrong position.
The Where clause argument is the 4th argument, not the 3rd.

I take it [Job+Control_Number] is the name of the field that contains
the record's Unique Prime Key value, as well as the name of the
control on the continuous form that is displaying that value.

If [Job_Control_Number] is a Number datatype field, then:

Private Sub Job_Details_BTn_Click()
On Error GoTo Err_Job_Details_BTn_Click
Dim stDocName As String
stDocName = "Open Status Board report by JCN"
DoCmd.OpenReport stDocName, acPreview, , "[Job_Control_Number] = " &
Me.[Job_Control_Number]

Exit_Job_Details_BTn_Click:
Exit Sub

Err_Job_Details_BTn_Click:
MsgBox Err.Description
Resume Exit_Job_Details_BTn_Click

End Sub


Note the added comma after acPreview.

However, if [Job_Control_Number] is Text datatype, then substiture:

DoCmd.OpenReport stDocName, acPreview, , "[Job_Control_Number] = '" &
[Job_Control_Number] & "'"

I suggest you read up on
Where Clause
as well as
Restrict data to a subset of records
in VBA help.
 
K

Klatuu

Assuming Job_Control_Number is a field or variable with the value you want to
filter your report on, there is just a minor syntax error. The code should
be:

DoCmd.OpenReport stDocName, acPreview, , SomeFieldName = Job_Control_Number

The 3rd argument is for using a query to filter the report. It expects a
query name. The forth argument is the Where condition that will filter on a
specific value.
In this case, SomeFieldName would be a field in the report's recordset that
you want to match the Job_Control_Number field on.
 
C

ColeVet67 via AccessMonster.com

I am sorry for my ACCESS ignorance but i am fairly new to this and not quite
up to speed. I do thank you for your input and recommendations. You are
correct in assuming that the Job_Control_Number is a field in the form which
holds a unique key. You are also correct in assuming that i do ONLY want the
one in which it is focused on. This JCN unique field is not access random
value... it is a sting (alphanumeric) which i coded to automatically
increment to next value.
See comments in line....
I have a DB continuous form with a button to display a form in print preview.
I need this button to only display the 1 form i am working with. If i press
the button all of the forms are available for print preview. They are listed
by JCN in the continuous form.

I would suggest you make a point of using the correct terminology when
asking for technical help. It makes it easier for us to help you.
You have one "form" (the continuous form) which is displaying many
"records". I suspect you wish to preview a "report" (a different
object) based upon just the one record that has the focus on your
continuous form.
here is the code:
[quoted text clipped - 3 lines]
Dim stDocName As String
Dim Job_Control_Number As String

Where below do you give a value to Job_Control_Number?
i.e. [Job_Control_Number] = ?
stDocName = "Open Status Board report by JCN"
DoCmd.OpenReport stDocName, acPreview, Job_Control_Number

Even if you had given Job_Control_Number a value, you have placed the
argument in the wrong position.
The Where clause argument is the 4th argument, not the 3rd.

I take it [Job+Control_Number] is the name of the field that contains
the record's Unique Prime Key value, as well as the name of the
control on the continuous form that is displaying that value.

If [Job_Control_Number] is a Number datatype field, then:

Private Sub Job_Details_BTn_Click()
On Error GoTo Err_Job_Details_BTn_Click
Dim stDocName As String
stDocName = "Open Status Board report by JCN"
DoCmd.OpenReport stDocName, acPreview, , "[Job_Control_Number] = " &
Me.[Job_Control_Number]

Exit_Job_Details_BTn_Click:
Exit Sub

Err_Job_Details_BTn_Click:
MsgBox Err.Description
Resume Exit_Job_Details_BTn_Click

End Sub

Note the added comma after acPreview.

However, if [Job_Control_Number] is Text datatype, then substiture:

DoCmd.OpenReport stDocName, acPreview, , "[Job_Control_Number] = '" &
[Job_Control_Number] & "'"

I suggest you read up on
Where Clause
as well as
Restrict data to a subset of records
in VBA help.
Exit_Job_Details_BTn_Click:
Exit Sub
[quoted text clipped - 6 lines]
Any help would be great
 

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