Hello,
First, let me say that my knowledge of this program is very, very basic. I've been tasked to make a slight change to a database we've used for a while now. Hopefully this will be an easy one for you.
Some background:
This is a database we use to track our competitor offerings. If a competitor is observed in the market, we will get samples, evaluate them, and generate a report (all done outside of Access). However, once all of that is done, we input key information into our Access database. We can then generate a basic report using the following form:
Very simple (that was all I was able to do)...basically you have a combo box that has 3 choices..."Complete", "Incomplete" and "All Evaluations". If it's blank, it defaults to all evaluations any way. Then, two text boxes to enter a date range. Pressing "Generate Report" runs a programatical query to search the various possibilities based on the status and date range. Here is a piece of that code:
Below this, there are a couple more If statements regarding the other possibilities, but they are basically the same. There is also the piece of code to sort on the evaluation status
This form works fine...returns a report that is sorted correctly by date and status.
Now, for the new portion. This is the part that I cannot get to work properly.
The only thing I am trying to add is a portion of code to filter out a specific competitor...I've censored that here as "CompetitorX", but in the code and in the database the actual competitor name is used. I am using the same style of form as I used previously - this one would just create a report with this competitor filtered out. I'm sure there's better ways to do it, but again, I'm really new at all of this and it seemed like the most efficient way for me to handle it.
At the beginning of that IF/THEN statement, you can see there is now a phrase added:
"& strValveName & " <> CompetitorX)"
Basically, the idea is to look at the table for under the column "Valve Name" and filter out the ones that have "CompetitorX" in that field. If I use the form with this string, an "Enter Parameter Value" box pops up with "CompetitorX" and a text box below. Doing a bit of research, I found that this means Access doesn't recognize "CompetitorX" for some reason, even though it's spelled exactly the same in the original table. This also happened when I did a bit of troubleshooting and replaced "Valve Name" with "Material" in the code (along with all the other stuff that goes with it). I got the same "Enter Parameter Value" box with whatever I was trying to filter out listed.
If I replace <>CompetitorX with <>"CompetitorX" I get an error (Compile Error: Expected: end of statement).
If I replace <>CompetitorX with <>""CompetitorX"" the code runs fine, but the CompetitorX data is not filtered out in the generated report
Am I doing something wrong in the Dim _ As _ portion to where it's not recognizing the value properly? Or am I doing something wrong in the If/Then portion? I just don't know where to look.
Is there a better way of doing this without using a statement in the If/Then portions of code? The filtered property does not ever need to change...it will always be "CompetitorX".
Thank you for any help. I really appreciate it. I hope this has been a good enough explanation...I apologize if I left something out.