Solved

Multiple conditions statement using sql

Posted on 2006-07-18
3
227 Views
Last Modified: 2008-02-26
I have a validation form that validates the user using 5 or so conditions with the results of the true condition gets written to a log table.  I cant seem to get it to work correctly.

conditions are -

1 - If the user is not in the database then write into the log "not found"
2 - if the user is found but has an expired membership the "membership expired"
3 - if the user is found but has no membership then "Invalid membership"
4 - if the user is in the database and all conditions are met then "Login success"

here is a sample of one of the conditions(this one is for login fail):

Dim rs1 As DAO.Recordset
    Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM my_table WHERE pin = '" & Me.pin & "'")
    If rs1.EOF Then
    Dim rs2 As DAO.Recordset
    Set rs2 = CurrentDb.OpenRecordset("SELECT * FROM log")
    rs2.AddNew
    rs2!id_num = Me.pin
    rs2!Stamp = Now()
    rs2!Station = Environ("computername")
    rs2!Action = DLookup("login_responder", "messages", "msg_cde = 'LIF'")
    rs2.Update
end if

0
Comment
Question by:H-SC
  • 2
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 17130660
Hi H-SC,
Looking through the entire post, it seems that pin might be a number datatype.

if, so you want....

 ("SELECT * FROM my_table WHERE pin = " & Me.pin )

Pete
0
 
LVL 1

Author Comment

by:H-SC
ID: 17131845
Pete,

I looked and the pin is text.  I should have explained more what I am seeing on as far as errors go.  I am getting a compile error - End if without block if.  Sould I be using else between these statements of end if?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17132843
The code segment you have posted is complete in terms of If statements.
Obviously I can't see the rest so have no idea where the missing End if should go.

Pete

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question