473,382 Members | 1,766 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,382 software developers and data experts.

Lookup and return value in a field

Hi, I urgently need help please.

I have the following:

Form - UserLogin with these unbound text boxes on it namely: txtOperator, txtUsername, txtPassword

Table - Operators with the following fields
Operator, Username, Password

My scenario is:
If I type something in txtOperator, then it must return the Username of that Operator from the table into the txtUsername unbound field.

Also when I type the password in the unbound txtPassword field, it must look up in the table if the txtPassword matches with Password from the table.

Further I can add in what I want.

Will someone PLEASE help me to find a solution for this. I have tried lookups and functions but no luck.

Your help is much appreciated - Thanks

Ryno
Nov 24 '10 #1
2 1501
TheSmileyCoder
2,322 Expert Mod 2GB
You could try this code in the LostFocus event of txtOperator

Expand|Select|Wrap|Line Numbers
  1. Me.txtUsername=nz(Dlookup("Username","tbl_Operators","Operator='" & txtOperator & "'"),"Not found")
Now assuming you have the user press a btn_Login after typing their password (The button is mostly there because after typing their password, people have no place to go, thus LostFocus doesn't fit well for this event). So in the OnClick of the button:
Expand|Select|Wrap|Line Numbers
  1. If me.txtPassword & "" ="" then
  2.   msgbox "You must type your password please."
  3.   Exit Sub
  4. End If
  5. If Dlookup("Password","Tbl_Operators","Operator='" & Me.txtOperator & "'") & ""=me.txtPassword then
  6.   Docmd.close
  7.   Docmd.Openform "Your form name goes here"
  8. else
  9.   msgbox "Password does not match password in storage"
  10. end if
Now while this should work, I strongly urge you to encode the passwords you store in a table, using a one-way encryption scheme. Otherwise the password will be readable straight from the table.
Nov 25 '10 #2
Hi,

Thanks for your reply. All working just fine!!

Thank you
Nov 25 '10 #3

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

Similar topics

3
by: Gunnar Liknes | last post by:
Hi, Is it possible to make a stored procedure or function to generate a return value? I have a stored procedure which inserts a new row in a table. I would like that proceudre to return the...
4
by: Kevin Goodsell | last post by:
The return value of sscanf should be "the number of input items assigned" (unless an input failure occurs before any conversion). Are items assigned due to a "%n" directive included in the returned...
3
by: Tom | last post by:
Hi, I wrote the following code in a c# winform. InternetExplorer ie = new InternetExplorer(); ie.Navigate(url, ref o, ref o, ref o, ref o); The url can be passed to the IE. However, how...
2
by: Mike P | last post by:
I have a SQL Server stored procedure that is returning a 0 if the execution was OK and 1 if not. e.g. : commit trans return 0 on_error: rollback tran
2
by: Hans Kesting | last post by:
Hi, For a problem I'm having a solution could be to apply the SoapAttributeAttribute to the return value of my method. The documentation says it's possible, even the errormessage I'm getting...
4
by: Mark Kamoski | last post by:
Hi Everyone. What is the real difference between writing a Sub versus writing a Function with no return value? It seems to me that both of these would need to compile to the same IL, so it...
1
by: Sam | last post by:
Hi, I don't know how to specify the display and value field for a combobox when using AddRange to fill the combo. Here is what I have so far: -A function to build an array of object : Dim...
3
by: Toco | last post by:
Hello. I have method (called GetKey) in a class that returns a string. Also, I have in another class, a method which makes a call to the GetKey method. What I wish to do is to do an evaluation of...
1
by: mailpitches | last post by:
X-No-Archive: yes a function, the return value of the function is a boolean. What does this boolean value mean? Example: <body onload="document.getElementById('field').onkeydown=function(x) {...
4
by: Zytan | last post by:
It seems I cannot return a reference to a value type as the return value of a method. I will have to use an out parameter instead. Is there another way to do it? Zytan
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.