ip compare DB field loginIP to REMOTEadr

I have a from that a visitor completes. It saves the form in an access db with current date (date format) as dateadded and Request.ServerVariables("REMOTE_ADDR") as loginIP (textfield). There a a couple of field saved but the are not important at this time.
Once the visitor completes the form they can not resubmit another form until the next day. So if a visitor tries to submit a second form on the same day they are sent to a "too bad fo you you have to wait until tomorrow" page.

I query the table  where the dateadded equal date() and loginIP=Request.ServerVariables("REMOTE_ADDR") Right now I can get the new ip from the second attempt to submit another form and I can response.write both the dateadded and the loginIP but when i query it nothing happens. I have looked all over the web for a solution but i can't find a solution or a part solution I can expand on. I ahve attached the code I am having a problem with.newtest.txt
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
I used a simpler page to test this.  I had to change the SQL string to put '#' around the date and single quotes around the IP address text.
SQL = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'"

Open in new window

DDeanAuthor Commented:
Dave,it still isn't selecting base on the where. Could it be possible may structure is wrong

there 3 fields
dateadded - type: date/time short date added as default
selection - type: text length 50
loginIP - Type: text length 15 123.456.789.012 ( the length was 14. fixed ... that still no work

here is the code that I last tried

If I don't select 'where' I can list all the fields including the calculated fields


I am beginning to feel rather stupid. In my mind the code should work
DDeanAuthor Commented:
Forgot the code
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Dave BaldwinFixer of ProblemsCommented:
Attached is the code I used for testing along with all the sections I commented out.
DDeanAuthor Commented:
it does the 'Response.Write("final date2:  " & finaldate2 & "  this is new IP:  "&NewIP) '

and I was getting tat as well.. but it doesn't do 'SQLstr = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'" '

nothing happens I get the response write at the top but the compare selection in the do while and the response at the bottom do nothing as if the 'do while' isn't finding anything.
Dave BaldwinFixer of ProblemsCommented:
Don't know what to tell you.  It's works exactly as described here.  I would have to add entries for it to find anything for today.  'today' is the date it is comparing it to.  Your code won't find anything else as it is written.
DDeanAuthor Commented:
date records I have been using:

Table: Contestvotes

dateadded      selection          loginIP
5/8/2015            2       
5/10/2015          1       
5/10/2015          2       


dateadded      Date/Time
selection         Text(50)
loginIP             Text(15)

It in theory it should only find the second record ... the ip listed is my IP so I should get the 'sorry you can't vote again until tomorrow'

All I want is to prevent someone from adding a second vote until the next day. If there is a better way to do this, I am all ears. To me, my code seemed to be simple logical way to achieve this .. but apparently not  
 : (
Dave BaldwinFixer of ProblemsCommented:
It's a weird one. Apparently ASP VBscript is still aware of the 'date' format when you do the comparison.  When I used 'Cstr' to convert it, then it works.  Updated code attached.
DDeanAuthor Commented:
we are half waythere. the 'sorry' displays but when I changed the last day I voted to 5/8/2015 I should get the contest message but is goes to the 'sorry' message.  

I tried changing the sql to
SQLstr = "SELECT * FROM Contestvotes where dateadded < #" & finaldate & "# and LoginIP = '" & NewIP & "'"

And all I got was a blank page ...
Dave BaldwinFixer of ProblemsCommented:
That version with '<' is doing a string comparison, not really a date comparison.
Dave BaldwinFixer of ProblemsCommented:
I just checked from another computer which also is in that database... and the obvious occurred to me.  The SQL statement selects Only those records with the current date and IP address... so it will Never show the contest message the way it is written.  If I change it to...
SQLstr = "SELECT * FROM Contestvotes where LoginIP = '" & NewIP & "'"

Open in new window

then it will find all of the entries for that IP address and if none are for today's date, then the 'contest' message will show.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DDeanAuthor Commented:
I think you did it !!! I will try this in the morning ... my brain is FULL
DDeanAuthor Commented:
But it looks like it worked !! I truly can't thank you enough!! Happy Happy
DDeanAuthor Commented:
Like I said ... Happy Happy !!!
Dave BaldwinFixer of ProblemsCommented:
A further addition because you want the most recent entry first...
SQLstr = "SELECT * FROM Contestvotes where LoginIP = '" & NewIP & "' ORDER BY dateadded DESC""

Open in new window

Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.