A non case sensitive database match

10-26-2004, 12:57 PM
I am using a Vb program and I am writing to an Access database. This program is to allow kids to take virtual tests that I created in the problem earlier. Everything works perfectly except for the fact that when the student enters the answer to the question it marks it wrong if it is in lower case, because I entered all the correct answers in upper case. Can someone please help make the problem except both upper and lower case answers as being correct. The answers are all one letter, if that helps at all. I am using Access 2002, VB 6 and the DAO code. Thanks for the help before hand.

10-26-2004, 01:21 PM
All you should need to do is force the correct case when checking against your database using either UCase() or LCase()...


10-27-2004, 12:02 PM
How do I use the UCase and LCase commands?

10-27-2004, 12:11 PM
Should I use them like this?

Correct = Table.Fields(UCase("CorrectAns")).Value
Correct2 = Table.Fields(LCase("CorrectAns")).Value

10-27-2004, 12:40 PM
More like this...

Pick one or the other (I'm going to go with UCase())...

When the user enters their answer, apply UCase() to the variable it's being stored in:

strAnswer = UCase(strAnswer)

Then, then you check it against the database:

if strAnswer = UCase(Table.Fields("CorrectAns").Value) Then
'user is correct
'user is wrong
end if

Hope this makes sense! :)

additionally, if you are using SQL to get your data, you can apply UCase() (or somethign similar) directly to the query...

10-27-2004, 01:05 PM
Thank you so very much, that not only made a lot of sense but it also made my program work 100% correctly. I thank you.

10-27-2004, 01:30 PM
No problem!

FYI - The only reason I suggested putting the UCase()/LCase() on both the submitted answer and the answer from the database is so that you would guarantee that you were always working with the same case. If you are 100% confident that what's in the database will always be either upper or lower case, then you only need to apply UCase()/LCase() to what the user enters...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum