Solved

Multiple conditions statement using sql

Posted on 2006-07-18
3
195 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now