Solved

Multiple conditions statement using sql

Posted on 2006-07-18
3
240 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

632 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