please someone, please help! 
Author Message
 please someone, please help!

Hi all,
         I bow to your immense knowledge and skill. please help me with this
one before I go completely insane.......

I have an access 2000 table
it has 2 fields
it's for a login screen but different to most, I wont bore you with the
details

table = Users

Users     Password
John       please
mike       sugar
amy        milk
paul        coffee

Easy?
 All I want is a query that I can ask what password corresponds to which
user

If I say the user is John then the query will return please

If I say the user is  amy then the query returns milk

anyone help me construct a query for this,,,,, please?

Thanks for your time
John



Fri, 20 Aug 2004 04:44:55 GMT  
 please someone, please help!
I assume you want to check the inputted text in the dialog

Private Sub cmdPassWord_Click

Dim strSql as string
Dim strUserName as string
Dim strPassword as string
Dim rsTemp as recordset

strUserName = Trim(txtUser.text)
strPassword = Trim(txtPassword.text)

Set rsTemp = new recordset
strSql = "Select Password from tblPasswords Where Users = " & strUserName

With rsTemp
    .cursorlocation = adueseclient
    .open strSql,Conn,adOpenForwardOnly,adReadOnly,adCmdText
    If not .eof Then
        If Password = strPassword Then
            'PasswordOK
        Else
            MsgBox "Incorrect Password for this user"
        End if
    Else
       MsgBox "User Name doers not exist
    End if
End with

Set rsTemp = nothing

End Sub

Take what you want

VOrtex


Quote:
> Hi all,
>          I bow to your immense knowledge and skill. please help me with
this
> one before I go completely insane.......

> I have an access 2000 table
> it has 2 fields
> it's for a login screen but different to most, I wont bore you with the
> details

> table = Users

> Users     Password
> John       please
> mike       sugar
> amy        milk
> paul        coffee

> Easy?
>  All I want is a query that I can ask what password corresponds to which
> user

> If I say the user is John then the query will return please

> If I say the user is  amy then the query returns milk

> anyone help me construct a query for this,,,,, please?

> Thanks for your time
> John




Fri, 20 Aug 2004 05:24:41 GMT  
 please someone, please help!
John,

You have a couple of options when using dynamic SQL - you can use a
generalized sql statement with parameters (wildcard/placeholders) or you can
build the sql statement in code -- each will work, and there are pros/cons
and biases for each --

Have a look at the MSDN help for the ADO Command and Parameter objects.
There is quite a bit of VB sample code there.

regards,
roy fine

p.s. - i you can't find anything, scan the following code hack -  there is
absolutely no error checking, no warranty,  and no attempt to handle case
sensitivty in the user name parameter.  all the best, rlf

' ********************************
Dim strUserName as String
Dim strPassword as String

Dim cnxion As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim recset As ADODB.Recordset

Dim intRoyalty As Integer
Dim strAuthorID As String

' You probably want to pass this in as an argument
strUserName = "John"

' Open our connection
Set cnxion = New ADODB.Connection
cnxion.Open "Your connection string goes here"

' Setup our command object
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cnxion
cmd.CommandText = "Select Password From Users Where Users= ?"
cmd.CommandType = adCmdText

' Create Param obj and assign value
Set prm = cmdByRoyalty.CreateParameter("USER", adChar, adParamInput)
cmd.Parameters.Append prm
prm.Value = strUserName

' Execute our Command, get recordset results
Set recset = cmd.Execute

' Do something with password
strPassword = recset!Password

' Cleanup and shutdown
recset.Close
cnxion.Close
Set cnxion = Nothing
Set recset = Nothing

' ********************************


Quote:
> Hi all,
>          I bow to your immense knowledge and skill. please help me with
this
> one before I go completely insane.......

> I have an access 2000 table
> it has 2 fields
> it's for a login screen but different to most, I wont bore you with the
> details

> table = Users

> Users     Password
> John       please
> mike       sugar
> amy        milk
> paul        coffee

> Easy?
>  All I want is a query that I can ask what password corresponds to which
> user

> If I say the user is John then the query will return please

> If I say the user is  amy then the query returns milk

> anyone help me construct a query for this,,,,, please?

> Thanks for your time
> John




Fri, 20 Aug 2004 05:47:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

3. VB Problem, Someone Please, Please Help!!

4. VB Problem, Someone Please, Please Help!!

5. I NEED SOMEONE EXPERIENCED TO HELP PLEASE ........PLEASE........

6. PLEASE HELP PLEASE HELP PLEASE HELP

7. Will someone please Reply ? (((((( Please))))))))

8. Need some help with some Access coding if someone could please help =)

9. SOMEONE HELP PLEASE---NEED VB HELP

10. Design Help PLEASE PLEASE PLEASE!

11. Please Please PLEASE HELP!!!!!

12. URGENT HELP PLEASE PLEASE PLEASE???

 

 
Powered by phpBB® Forum Software