Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiple conditions statement using sql

Posted on 2006-07-18
3
Medium Priority
?
244 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 1000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

730 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