cmd button to open report

  • Thread starter Thread starter hermie
  • Start date Start date
H

hermie

Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman
 
hi hermie,
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss
Why I cannot see the results in the report? Am I misisng something?
Your combobox has a property which is of interest here: .Value. Take a
look at the online help.

mfG
--> stefan <--
 
Gutentag Stefan

I looked in help for value but cannot find any reference related to my
problem? Should I put a me.value or something like that in my combobox?

herman
 
Hi stefan

I changed me.cboss in me.cboss.value but still have no data in the report?

You have other solution?

Herman
 
Stefan
For your information, when i go to next record and click the command button
then its shows data but its shows all records

Herman
 
hi herman,
I changed me.cboss in me.cboss.value but still have no data in the report?
Check if me.cboss.value holds the correct value (msgbox or denug.print).
If it has the correct data, check types. Is it a string, then add quotes
to your where condition, e.g. "ss='" & me.cboss.value & "'".

In any other case, open your report in design view, check your record
source in the query designer, if it returns any record.
If it does so, try to filter your field manually in the dataview. Are
there still any datarows left?

mfG
--> stefan <--
 
Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman

Herman,
You're syntax is incorrect.
The correct syntax depends upon the datatype of the [SS] field.
If the [SS] field is a Number datatype, then:

"[ss] = " & Me!cboss

If the [SS] field is a Text datatype, then:

"[ss] = '" & Me!cboss & "'"

Also, the bound column of the combo box is the column passed to the
the where clause, regardless of the column actually displayed in the
combo box.
Make sure the datatypes match.

For me it's easier the use the comma argument placement method:

DoCmd.OpenReport "Report materia with borders solo uno",
acViewPreview, , "[ss] = " & Me!cboss

Also, if you have newly created or edited the record and it has not
been saved, you must explicitly save it before running the report,
otherwise the new data will not be shown.
Write:

DoCmd.RunCommand acCmdSaveRecord

just BEFORE you open the report.
 
Hi Fred

My field related is a text field
But still not have the result as I like to have it.

I put now this in the on click event:

Private Sub Command48_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Report materia with borders solo uno", _
acViewPreview, , "[ss] = " & Me!cboss
End Sub

I think i need to put the command "DoCmd.RunCommand
acCmdSaveRecord"somewhere else

Herman
fredg said:
Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman

Herman,
You're syntax is incorrect.
The correct syntax depends upon the datatype of the [SS] field.
If the [SS] field is a Number datatype, then:

"[ss] = " & Me!cboss

If the [SS] field is a Text datatype, then:

"[ss] = '" & Me!cboss & "'"

Also, the bound column of the combo box is the column passed to the
the where clause, regardless of the column actually displayed in the
combo box.
Make sure the datatypes match.

For me it's easier the use the comma argument placement method:

DoCmd.OpenReport "Report materia with borders solo uno",
acViewPreview, , "[ss] = " & Me!cboss

Also, if you have newly created or edited the record and it has not
been saved, you must explicitly save it before running the report,
otherwise the new data will not be shown.
Write:

DoCmd.RunCommand acCmdSaveRecord

just BEFORE you open the report.
 
Fred

Now it works
Due to different examples you give me it I was confused

I now used: DoCmd.OpenReport "Report materia with borders solo uno", _
acViewPreview, , "[ss] = '" & Me!cboss & "'"

and this works

Thanks for your help

Herman
fredg said:
Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman

Herman,
You're syntax is incorrect.
The correct syntax depends upon the datatype of the [SS] field.
If the [SS] field is a Number datatype, then:

"[ss] = " & Me!cboss

If the [SS] field is a Text datatype, then:

"[ss] = '" & Me!cboss & "'"

Also, the bound column of the combo box is the column passed to the
the where clause, regardless of the column actually displayed in the
combo box.
Make sure the datatypes match.

For me it's easier the use the comma argument placement method:

DoCmd.OpenReport "Report materia with borders solo uno",
acViewPreview, , "[ss] = " & Me!cboss

Also, if you have newly created or edited the record and it has not
been saved, you must explicitly save it before running the report,
otherwise the new data will not be shown.
Write:

DoCmd.RunCommand acCmdSaveRecord

just BEFORE you open the report.
 
Fred

I have 1 additional question
What is the purpose of ' after [ss] = and & "'" after me!cboss?

Herman


fredg said:
Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman

Herman,
You're syntax is incorrect.
The correct syntax depends upon the datatype of the [SS] field.
If the [SS] field is a Number datatype, then:

"[ss] = " & Me!cboss

If the [SS] field is a Text datatype, then:

"[ss] = '" & Me!cboss & "'"

Also, the bound column of the combo box is the column passed to the
the where clause, regardless of the column actually displayed in the
combo box.
Make sure the datatypes match.

For me it's easier the use the comma argument placement method:

DoCmd.OpenReport "Report materia with borders solo uno",
acViewPreview, , "[ss] = " & Me!cboss

Also, if you have newly created or edited the record and it has not
been saved, you must explicitly save it before running the report,
otherwise the new data will not be shown.
Write:

DoCmd.RunCommand acCmdSaveRecord

just BEFORE you open the report.
 
Fred

I have 1 additional question
What is the purpose of ' after [ss] = and & "'" after me!cboss?

Herman

fredg said:
Hello

On my data entry form I created an command button to open a report. After
the data is entered the user can click the commandbutton to open a report to
view the results of the data entered.however when I click the command button
it opens the report but now shows data?

the event property of the commandbutton is:
Private Sub Command48_Click()
DoCmd.OpenReport "Report materia with borders solo uno", acViewPreview,
whereCondition:="ss" = Me.cboss

End Sub

me.cboss is the reference to the comobox on the data entry form and ss is
the reference on the report.

Why I cannot see the results in the report? Am I misisng something?

Herman

Herman,
You're syntax is incorrect.
The correct syntax depends upon the datatype of the [SS] field.
If the [SS] field is a Number datatype, then:

"[ss] = " & Me!cboss

If the [SS] field is a Text datatype, then:

"[ss] = '" & Me!cboss & "'"

Also, the bound column of the combo box is the column passed to the
the where clause, regardless of the column actually displayed in the
combo box.
Make sure the datatypes match.

For me it's easier the use the comma argument placement method:

DoCmd.OpenReport "Report materia with borders solo uno",
acViewPreview, , "[ss] = " & Me!cboss

Also, if you have newly created or edited the record and it has not
been saved, you must explicitly save it before running the report,
otherwise the new data will not be shown.
Write:

DoCmd.RunCommand acCmdSaveRecord

just BEFORE you open the report.

When you are using a text datatype as criteria, the text value must be
surrounded by either a " or a '.
When the above code is run, the
"[SS] = '" & CBox & "'"
returns the value as:
"[SS] = 'Herman'"
Notice the name Herman is surrounded by single quotes.
You must use single quotes in this instance because the double quote "
is already in use.
 
Back
Top