473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

compare values entered into text boxes with fields in table

8
hi:
i want to compare the values that entered into text boxes with fields in table
if it exists in the table i want to open page called (result)
else open(voting)
but when i run the program my code in two cases open the result page
here is my code
Expand|Select|Wrap|Line Numbers
  1. If Me.f2.Value = DLookup("Passwords", _
  2.       "Passwords", _
  3.       "[Names]='" & Me.f1.Value & "'") Then
  4.    '
  5.    DoCmd.Close acForm, "Main form", acSaveNo
  6.    DoCmd.OpenForm "result"
  7. ElseIf Me.f2.Value <> DLookup("Passwords", _
  8.       "Passwords", _
  9.       "[Names]='" & Me.f1.Value & "'") Then
  10.    '
  11.    DoCmd.Close acForm, "Main form", acSaveNo
  12.    DoCmd.OpenForm "Voting"
  13. End If
  14.  
Mar 8 '13 #1
7 5233
Seth Schrock
2,965 Expert 2GB
Please read Use a good thread title

I think you have a slight misunderstanding of how the If/Then/Else statement works. You don't need to test for the Me.f2 <> Dlookup... as that would be the same as the false of Me.f2 = Dlookup... so the Else portion of the code would run. Try the following
Expand|Select|Wrap|Line Numbers
  1. If Me.f2.Value = DLookup("Passwords", "Passwords", "[Names]='" & Me.f1.Value & "'") Then
  2.     DoCmd.OpenForm "result"
  3. Else
  4.     DoCmd.OpenForm "Voting"
  5. End If
  6.  
  7. DoCmd.Close acForm, "Main form", acSaveNo
Mar 8 '13 #2
aannll
8
thanks for your answer
but also when i use this code
in two cases it open the result page
Mar 8 '13 #3
Seth Schrock
2,965 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Dim strPassword as String
  2. strPassword = DLookup("Passwords", "Passwords", "[Names]='" & Me.f1.Value & "'")
  3.  
  4. Debug.Print strPassword
  5. Debug.Print Me.f2
  6.  
  7. Stop
  8. If Me.f2.Value = strPassword Then
  9.     DoCmd.OpenForm "result"
  10. Else
  11.     DoCmd.OpenForm "Voting"
  12. End If
  13.  
  14. DoCmd.Close acForm, "Main form", acSaveNo
Try the above code. Execution will stop on line 7. Check the values in the immediate window (Ctrl + G opens it). Now press F8 to step through the code one line at a time. Tell me if the values in the immediate window are equal or not and then which lines of code were executed going through the If/Then/Else statement.
Mar 8 '13 #4
aannll
8
the values in the immediate window are equal
and the lines 8 9 12 14 are executed
Mar 8 '13 #5
Seth Schrock
2,965 Expert 2GB
Those are the results that I would expect. Now try it with the wrong password. I assume this is where you are having the problem?
Mar 8 '13 #6
aannll
8
the value not in the table but it appear equal in the immediate window and take the same steps to the result page
Mar 8 '13 #7
Seth Schrock
2,965 Expert 2GB
Normally I would ask what the values in the immediate window are, but since they are passwords, I'll let you do the checking.

You type in a wrong password (X)
The script runs and it gives you what the correct password is (Y) and what it sees in your password textbox (Z)

Are X and Z equal, and Y and Z not equal?
Mar 8 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Flack | last post by:
Hello, When the user of my app selects some rows from an open excel file and drag-n-drops them onto my form, I need to be able to parse those lines and create a datatable that would match the...
3
by: Bilal | last post by:
hi all I am facing a little problem. I have a form with a dropdownlist control. I have a button and when i click the form posts back The problem is that in the on button click event i'm calling...
0
by: Miguel Dias Moura | last post by:
Hello, I created MyPage.aspx and MyPage.aspx.vb in VS2005. I also added a few images to the local resource file MyPage.aspx.resx I added an asp:Image to MyPage.aspx with ID="MyImage". I need...
5
by: jayparaiso | last post by:
Hi Newsgroups, I'm begginner for web designing. i want to create registration page, what are the things to be considered? Please let me know how to create a dynamic form like log in and password,...
1
by: shapper | last post by:
Hello, For the past hours I have been trying to solve a problem which is driving me crazy. I have to different codes where the problem to solve is the same: CODE 1 (Transforms a XML...
4
by: shapper | last post by:
Hello, I placed a textbox in a web page where I ask the user for its email. Now I need to reset its password and get the user profile for the given email if it exists. How can I do this? ...
3
by: jats | last post by:
I am a .NET programmer and i had recently got a web application designed in Classic ASP, to make some modifications. When i run the application and try to create a new user the following error...
3
by: shapper | last post by:
Hello, I am working on an ASP.MET MVC Web Application with NET 3.5 in VS 2008. I need to run some extra tasks on this project build so I download MSBuild from http://msbuildtasks.tigris.org/....
3
by: shapper | last post by:
Hello, I have three tables: Polls (PollId, Question), Options (OptionID, Answer) and Votes (VoteID, OptionID) I then created two Wrapper Classes: PostPaper with the following properties:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.