Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with some coding 1

Status
Not open for further replies.

jdwm2310

Technical User
Jul 26, 2001
396
US
Hi Guys,

I wrote up this code and it's working perfectly on another database but when I use it for this new database, I get a blank form.

Dim stDocName As String
Dim strCrit As String

stDocName = "SERP Plan Report"
strCrit = "[Employee Data] = '" & Me.Text16 & "'"

DoCmd.OpenReport stDocName, acViewPreview, , strCrit
 
Well, you said you copied the line from another database. Did you copy it verbatim or did you change the report name, table name, etc?

Check to make sure your criteria line is accurate. Is "[Employee Data]" a field in this report's recordsource? Is text16 a valid field on your form? If so does text16 store Employee data? Maq B-)
<insert witty signature here>
 
Ok now I am prompt with a parameter. I don't know why but I don't want that to occur.

Dim StDocName As String
Dim StrCrit As String

StDocName = &quot;Report Name&quot;
StrCrit =&quot;[Field Name]=&quot; &Me.TextBox&quot;'&quot;

DoCmd.OpenReport StDocName,AcPreview,,StrCrit

 
You entered a parameter in your StrCrit statement. Replace [Field Name] with the actual field name. Also, is textbox the actual name of your textbox? If so, I would definitely recommend changing the name before Access has a heartattack over it. Maq B-)
<insert witty signature here>
 
Hi,

I think you've missed out a single quote in the criteria.

Try,

StrCrit =&quot;[Field Name]='&quot; &Me.TextBox & &quot;'&quot;

HTH

Jane
 
Hi Maquis,
I didn't copy the code verbatim. This is how it looks in the event procedure of the the preview button.

Dim stDocName As String
Dim strCrit As String

stDocName = &quot;SERP Plan Report&quot;
strCrit = &quot;[EmployeeName] ='&quot; & Me.Text16 & &quot;'&quot;

DoCmd.OpenReport stDocName, acViewPreview, , strCrit

When I click on the preview button I am prompt with a parameter variable. Any suggestions
 
That looks ok to me. The parameter variable may be coming from the recordsource of your report or from the sorting and grouping values in the report.

[EmployeeName] is a field in your report right? If so check the other places for the parameter name. Maq B-)
<insert witty signature here>
 
Hi Maquis,

It's working now, the problem was that the field name did not match the field name of the report. Now it's working perfectly....Thanks for pointing that out....;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top