Try printing Qry right after you set it to make sure it has the value you want. Maybe print other values as well.
For Get ParameterByText to work, you need to have made the script a tool, or run it from the command line with arguments. I recommend hard coding some values in for testing. Once it works there, you can switch to parameters.
Thank you for reminding me to do this. I have been testing it as a tool (since that is my ultimate goal) but hard coding it is a good idea so I tried that, but now I am getting a syntax error that I cannot figure out. Here is the 'new' code.... syntax Error is associated with #Establish material search for tool: Qry is invalid syntax.
import arcpy
# Set workspace
arcpy.env.workspace = r"G:\Olson-Murphy_Week10\SouthFloridaNaturalGas.gdb"
#Estabslish input feature class
fc = r"G:\Olson-Murphy_Week10\SouthFloridaNaturalGas.gdb\Mains"
# Establish Class fields
Field = ["Material", "Diameter", "System]"
# Establish materials search for tool
Qry ="Material = Plastic"
# Establish Class fields
Field = ["Material", "Diameter", "System]"
#Define output
outReport = arcpy.GetParameterAsText(1)
#Open the report text file in write mode
file = open (outReport, "w")
#Add Header lines to report text file
file.write("Mains found in this report include:\n")
file.write("Material:" + Qry + "\n")
# Create cursor to search gas mains by material
arcpy.da.SearchCursor(fc,Qry, fields) as Qry:
for row in Qry:
rptMat = str(row.getValue("Material"))
rptDiam = str(row.getValue("Diameter"))
rptSys = str(row.getValue("System"))
file.write(rptMat + " " + rptDiam + " " + rptSys + "\n")
del Qry, row