Solved

Multiple conditions statement using sql

Posted on 2006-07-18
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

739 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