How print record using a input box on a Report

J

jeanhurtado

Hi I'm Jean and well I making a database project. I have the following
issue:

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Example:

Private Sub PRINT_REPORT_Click()

Dim strReportName As String
Dim strCriteria As String


strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub

Thanks in advance for all. Have a nice day.


sincerely your's
Jean C.
 
J

jeanhurtado

ok let me explain better. I a button on a form that can print an
specified record that will be entered in and input box. I have trying
to customize this code to erform that condition. I want an specific
record that will be the asset number field that will be entered in a
input box.



This code is the Click event of a command button named PRINT_REPORT. I doubt
you actually need to present an input box in this case. According the the
code, the Assest Number is already on the form in a control named [ASSET
NUMBER]. So what is not working?
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
Hi I'm Jean and well I making a database project. I have the following
issue:

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Example:

Private Sub PRINT_REPORT_Click()

Dim strReportName As String
Dim strCriteria As String


strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub

Thanks in advance for all. Have a nice day.


sincerely your's
Jean C.
 
J

jeanhurtado

ok let me explain better. I want button on a form that can print an
specified record that will be entered in and input box. I have trying
to customize this code to perform that condition. I want an specific
record that will be the asset number field that will be entered in a
input box then print the record in report.


Klatuu said:
This code is the Click event of a command button named PRINT_REPORT. I doubt
you actually need to present an input box in this case. According the the
code, the Assest Number is already on the form in a control named [ASSET
NUMBER]. So what is not working?
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
Hi I'm Jean and well I making a database project. I have the following
issue:

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Example:

Private Sub PRINT_REPORT_Click()

Dim strReportName As String
Dim strCriteria As String


strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub

Thanks in advance for all. Have a nice day.


sincerely your's
Jean C.
 
J

jeanhurtado

ok let me explain better. I want button on a form that can print an
specified record that will be entered in a input box. I have trying
to customize this code to perform that condition. I want an entered
record that will be the asset number field that will be entered in a
input box then print the record in report.


Klatuu said:
This code is the Click event of a command button named PRINT_REPORT. I doubt
you actually need to present an input box in this case. According the the
code, the Assest Number is already on the form in a control named [ASSET
NUMBER]. So what is not working?
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
Hi I'm Jean and well I making a database project. I have the following
issue:

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Example:

Private Sub PRINT_REPORT_Click()

Dim strReportName As String
Dim strCriteria As String


strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub

Thanks in advance for all. Have a nice day.


sincerely your's
Jean C.
 
J

jeanhurtado

ok let me explain better. I want button on a form that can print an
specified record that will be entered in a input box. I have trying
to customize this code to perform that condition. I want an entered
record that will be the asset number field that will be entered in a
input box then print the record in a report.


Klatuu said:
This code is the Click event of a command button named PRINT_REPORT. I doubt
you actually need to present an input box in this case. According the the
code, the Assest Number is already on the form in a control named [ASSET
NUMBER]. So what is not working?
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
Hi I'm Jean and well I making a database project. I have the following
issue:

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Example:

Private Sub PRINT_REPORT_Click()

Dim strReportName As String
Dim strCriteria As String


strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub

Thanks in advance for all. Have a nice day.


sincerely your's
Jean C.
 
M

Marshall Barton

I want to print a record entering a "Asset Number" filed (This field
is the PRIMARY KEY) in a input box and then print the entered record in
a Report. I have the code to print the current record in a report but I
don't know how to customize that code to use the entered data(input
box) as the record that I want to print.

Private Sub PRINT_REPORT_Click()
Dim strReportName As String
Dim strCriteria As String

strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & Me![ASSET NUMBER] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


I think this is the kind of thing you're looking for:

Private Sub PRINT_REPORT_Click()
Dim strReportName As String
Dim strCriteria As String
Dim strAssetID As String

strAssetID = InputBox("Enter Asset Number")
If strAssetID <> "" Then
strReportName = "ASSET REPORT"
strCriteria = "[ASSET NUMBER]='" & strAssetID & "'"
DoCmd.OpenReport strReportName, acViewPreview, ,
strCriteria
Else
Beep
End If
End Sub

I prefer to use an unbound text box on the form instead of
an input box, but it's your app.
 
J

jeanhurtado

Thanks Mr. Marshall Barton it works incredibly well. Thanks you so much
for help me.
Thanks Klatuu also for your help and consideration. Merry Christmas to
all. God Bless you.
 

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