473,668 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very - very - simple lookup example asked.

Hi,
I'd like to make my own very simple autorisation system.
Just a table: tblUsers (user and pw).
Next I need a form with user and pw in textbox, with an OK button.

If the lookup fails: msgbox "Wrong, bye!" and docmd.quit

If lookup succeeds: open the switchboard.

Now I'm not very familiar with the lookup function, and this is where I
get stuck.

Who can help?

Thanks

Nov 13 '05 #1
8 3176
<al********@it4 us.nl> schreef in bericht news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hi,
I'd like to make my own very simple autorisation system.
Just a table: tblUsers (user and pw).
Next I need a form with user and pw in textbox, with an OK button.

If the lookup fails: msgbox "Wrong, bye!" and docmd.quit

If lookup succeeds: open the switchboard.

Now I'm not very familiar with the lookup function, and this is where I
get stuck.

Who can help?

Thanks


Since this is very - very simple indeed, you might as well look it up yourself ...
Hint: Search for 'DLookup' in the Help and just study the examples.

Arno R

Nov 13 '05 #2
Not helpfull Arno. I get stuck in the following piece of code:
Private Sub Knop6_Click()
Dim varx As Variant

varx = DLookup("pw", "tblUsers", "User =" & """ Me![txtUser]&""")

If varx = Me!txtPw Then
MsgBox "Password Ok, please continue"
Else
MsgBox "Wrong! Get Out!"
End If

End Sub

I only get the "Wrong! Get Out!" reply, even on entries present in the
table.

Any helpfull suggestions??

Thx,
Paul

Arno R schreef:
<al********@it4 us.nl> schreef in bericht news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hi,
I'd like to make my own very simple autorisation system.
Just a table: tblUsers (user and pw).
Next I need a form with user and pw in textbox, with an OK button.

If the lookup fails: msgbox "Wrong, bye!" and docmd.quit

If lookup succeeds: open the switchboard.

Now I'm not very familiar with the lookup function, and this is where I
get stuck.

Who can help?

Thanks


Since this is very - very simple indeed, you might as well look it up yourself ...
Hint: Search for 'DLookup' in the Help and just study the examples.

Arno R


Nov 13 '05 #3
<al********@it4 us.nl> schreef in bericht news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Not helpfull Arno. I get stuck in the following piece of code:


Private Sub Knop6_Click()
Dim varx As Variant

varx = DLookup("pw", "tblUsers", "User =" & """ Me![txtUser]&""")

If varx = Me!txtPw Then
MsgBox "Password Ok, please continue"
Else
MsgBox "Wrong! Get Out!"
End If

End Sub

I only get the "Wrong! Get Out!" reply, even on entries present in the
table.

Any helpfull suggestions??


You are using the wrong syntax indeed, should be:
varx = DLookup("pw", "tblUsers", "User ='" & Me![txtUser] & "'"
(again with extra spaces for clarity only: "User= ' " & Me![TxtUser] & " ' " )

You could also use something like:
Dim strQuote as string
strQuote =Chr(34)
varx = DLookup("pw", "tblUsers", "User =" & strQuote & Me![txtUser] & strQuote)

Arno R
Nov 13 '05 #4
"Arno R" <ar***********@ tiscali.nl> wrote in message
news:42******** *************@d reader2.news.ti scali.nl...
<al********@it4 us.nl> schreef in bericht
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Not helpfull Arno. I get stuck in the following piece of code:
Private Sub Knop6_Click()
Dim varx As Variant

varx = DLookup("pw", "tblUsers", "User =" & """ Me![txtUser]&""")

If varx = Me!txtPw Then
MsgBox "Password Ok, please continue"
Else
MsgBox "Wrong! Get Out!"
End If

End Sub

I only get the "Wrong! Get Out!" reply, even on entries present in the
table.

Any helpfull suggestions??


You are using the wrong syntax indeed, should be:
varx = DLookup("pw", "tblUsers", "User ='" & Me![txtUser] & "'"
(again with extra spaces for clarity only: "User= ' " & Me![TxtUser] & " '
" )

You could also use something like:
Dim strQuote as string
strQuote =Chr(34)
varx = DLookup("pw", "tblUsers", "User =" & strQuote & Me![txtUser] &
strQuote)

Arno R
This may cause you trouble if the user's name is O'Connor. You could try my
function for adding quotes, which will avoid that problem:
Option Compare Database
Option Explicit

Public Enum QuoteType
NoQuote
SingleQuote
DoubleQuote
End Enum
Public Function AddQuotes(strVa lue, Q As QuoteType) As String

Dim strReturn As String

Select Case Q

Case QuoteType.Singl eQuote
strReturn = Replace(strValu e, "'", "''")
strReturn = "'" & strReturn & "'"

Case QuoteType.Doubl eQuote
strReturn = Replace(strValu e, """", """""")
strReturn = """" & strReturn & """"

Case Else
strReturn = strValue

End Select

AddQuotes = strReturn

End Function
Nov 13 '05 #5
"Justin Hoffman" <j@b.com> schreef in bericht news:d7******** **@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...
This may cause you trouble if the user's name is O'Connor. You could try my
function for adding quotes, which will avoid that problem:

Hi Justin,
When you use Chr(34), which provides a double quote, there is no problem with O'Conner and such.
You are right on this when using the first syntax however.
Just thought that the OP was merely struggling with the DCount syntax ....

Arno R

Nov 13 '05 #6
"Arno R" <ar***********@ tiscali.nl> wrote in message
news:42******** *************@d reader2.news.ti scali.nl...
"Justin Hoffman" <j@b.com> schreef in bericht
news:d7******** **@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...
This may cause you trouble if the user's name is O'Connor. You could try
my
function for adding quotes, which will avoid that problem:

Hi Justin,
When you use Chr(34), which provides a double quote, there is no problem
with O'Conner and such.
You are right on this when using the first syntax however.
Just thought that the OP was merely struggling with the DCount syntax ...

Arno R
Sure. If you've been coding a while, you must have done it all before, but
perhaps for the OP, coding like

strSQL=strSQL & AddQuotes(strUs er,DoubleQuote)

is quite readable (to me anyway)
Nov 13 '05 #7
Br
Justin Hoffman <j@b.com> wrote:
"Arno R" <ar***********@ tiscali.nl> wrote in message
news:42******** *************@d reader2.news.ti scali.nl...
<al********@it4 us.nl> schreef in bericht
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Not helpfull Arno. I get stuck in the following piece of code:
Private Sub Knop6_Click()
Dim varx As Variant

varx = DLookup("pw", "tblUsers", "User =" & """ Me![txtUser]&""")

If varx = Me!txtPw Then
MsgBox "Password Ok, please continue"
Else
MsgBox "Wrong! Get Out!"
End If

End Sub

I only get the "Wrong! Get Out!" reply, even on entries present in
the table.

Any helpfull suggestions??


You are using the wrong syntax indeed, should be:
varx = DLookup("pw", "tblUsers", "User ='" & Me![txtUser] & "'"
(again with extra spaces for clarity only: "User= ' " & Me![TxtUser]
& " ' " )

You could also use something like:
Dim strQuote as string
strQuote =Chr(34)
varx = DLookup("pw", "tblUsers", "User =" & strQuote & Me![txtUser] &
strQuote)

Arno R
This may cause you trouble if the user's name is O'Connor. You could
try my function for adding quotes, which will avoid that problem:


And what happens if someone enters one of the following as the user name
(incl quotes)?

" OR TRUE OR "

:) :)

<>

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #8
Hi,
I got it working now, with the StrQuote option that Arno suggested. I
think using a mask to prevent '":{:-)*_ from entering will be enough.
Paul

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3845
by: robin | last post by:
I need to do a search through about 50 million records, each of which are less than 100 bytes wide. A database is actually too slow for this, so I thought of optimising the data and putting it all in memory. There is a single key field, so a dictionary is an obvious choice for a structure, since Python optimises these nicely. But is there a better choice? Is it worth building some sort of tree?
1
1989
by: Srini | last post by:
I was reading the "Exceptional C++" of Herb Sutter. In an example, he mentions the following. // In some library header: namespace N { class C{}; } int operator+(int i, N::C) { return i+1; } // A mainline to exercise it: #include <numeric> int main() {
10
1862
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long int". I have a typedef for this: typedef unsigned long int Uint32; typedef float Float32; Uint32 myArray;
14
1715
by: Steve | last post by:
Sorry in advance for my ignorance. Any help would sure be appreciated. I'm writing a fairly simple application with VB.Net and am obviously a bit of a newbie. This application will be used by 1, 2 or at most 3 people concurrently and I'm using Access 2003 for my data source. We are not dealing with a large amount of data (5 or 6 tables, for a total of maybe 3,000 records - one table having the majority of that). This application is...
3
1846
by: larry | last post by:
Ok I am re-coding our apps in PHP and am looking for ways to make parts easily updateable, One of the challenges in my field (non-rpofit) are various lookup tables (for incomes etc). An example table would be something like a rate lookup, where you travel down the family size column and when you reach the right income you look for the rate. An example here: RATE - FAM2 -FAM3 - FAM4 - FAM5 100 - 1200 - 1300 - 1375 - 1380
3
1621
by: gmwebay | last post by:
I'm a physician and I need to keep track of the 10 procedures or so I do every day. I want to build an access database and have started. (Access 2003). I find the tutorials and help way beyond my level of expertise and ability. If I could get about five questions answered, I think I could get there. So... I have a form with about 11 fields on it (name, hosp number, procedure, etc). What I want is some sort of cascading list, for...
3
5318
by: Markw | last post by:
I think this was recently asked but I was a little lost on the example that was used so I'm reasking it with an example I can understand. Also forgive me for such a basic question but I really am new to Mysql and PHP. In the book "Build Your Own Database Driven Website Using PHP & Mysql" by Kevin Yank, they give an example for when using a many to many relationship that it is best to use a lookup table. The example they show of how it...
8
5023
by: schaf | last post by:
Hi NG! I have a problem in my remote application. After calling a remote function the calculation will be done by the service. The calculation result will be sent to the caller (client) via remote event. The following behavior can be observed: 1.) Right after the start of the server the first response via remote event will take a long time.
112
4662
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not work. To rule out all possible factors, I made up a dummy page for an index.html to upload, along the lines of <html><head><title></title></ head><body></body></html>.; the image-swap itself is your basic <img src="blah.png"...
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8577
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2786
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.