Welcome to Windows Help!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

if statement not working

 
   Windows Help (Home) -> Microsoft Access RSS
Next:  refering to a name range area as a reference valu..  
Author Message
deb

External


Since: Oct 29, 2008
Posts: 7



(Msg. 1) Posted: Mon Feb 01, 2010 9:40 am
Post subject: if statement not working
Archived from groups: microsoft>public>access (more info?)

Access 2003 code on forms oncurrent event... I want the below
If DLookup is Admin then
TitleMSP.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True
If DLookup is Admin and Not IsNull(Me.TitleMSP) then
TitleMSP.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True
If DLookup is anything other than Admin then
TitleMSP.Visible = False
ContactUserID.Visible = False
ContactStatus.Visible = False
Label97.Visible = False
Label96.Visible = False
Label95.Visible = True

Here is what I am trying. but it is not working quite right. Thanks in
advance for your help!!

If DLookup("[User_Type]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "Admin" Then
TitleMSP.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True

If Not IsNull(Me.TitleMSP) Then
TitleMSP.Visible = True
ContactUserID.Visible = True
ContactStatus.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True

Else
TitleMSP.Visible = False
ContactUserID.Visible = False
ContactStatus.Visible = False
Label97.Visible = False
Label96.Visible = False
Label95.Visible = True
End If
End If

 >> Stay informed about: if statement not working 
Back to top
Login to vote
Dorian

External


Since: Dec 4, 2008
Posts: 6



(Msg. 2) Posted: Mon Feb 01, 2010 10:21 am
Post subject: RE: if statement not working
Archived from groups: per prev. post (more info?)

else always applies to immediately preceding if

your first if determines 'admin' so last else needs to be matched to that.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"deb" wrote:

> Access 2003 code on forms oncurrent event... I want the below
> If DLookup is Admin then
> TitleMSP.Visible = True
> Label95.Visible = False
> Label97.Visible = True
> Label96.Visible = True
> If DLookup is Admin and Not IsNull(Me.TitleMSP) then
> TitleMSP.Visible = True
> Label95.Visible = False
> Label97.Visible = True
> Label96.Visible = True
> If DLookup is anything other than Admin then
> TitleMSP.Visible = False
> ContactUserID.Visible = False
> ContactStatus.Visible = False
> Label97.Visible = False
> Label96.Visible = False
> Label95.Visible = True
>
> Here is what I am trying. but it is not working quite right. Thanks in
> advance for your help!!
>
> If DLookup("[User_Type]", "[tblVersion]", "[UserID] = '" &
> Environ("username") & "'") = "Admin" Then
> TitleMSP.Visible = True
> Label95.Visible = False
> Label97.Visible = True
> Label96.Visible = True
>
> If Not IsNull(Me.TitleMSP) Then
> TitleMSP.Visible = True
> ContactUserID.Visible = True
> ContactStatus.Visible = True
> Label95.Visible = False
> Label97.Visible = True
> Label96.Visible = True
>
> Else
> TitleMSP.Visible = False
> ContactUserID.Visible = False
> ContactStatus.Visible = False
> Label97.Visible = False
> Label96.Visible = False
> Label95.Visible = True
> End If
> End If
> --
> deb

 >> Stay informed about: if statement not working 
Back to top
Login to vote
Douglas J. Steele

External


Since: Nov 27, 2008
Posts: 61



(Msg. 3) Posted: Mon Feb 01, 2010 12:50 pm
Post subject: Re: if statement not working
Archived from groups: per prev. post (more info?)

I believe your first End If is in the wrong place:
 >> Stay informed about: if statement not working 
Back to top
Login to vote
Douglas J. Steele

External


Since: Nov 27, 2008
Posts: 61



(Msg. 4) Posted: Mon Feb 01, 2010 12:54 pm
Post subject: Re: if statement not working
Archived from groups: per prev. post (more info?)

Oops: Hit Send too soon.

I believe your first End If is in the wrong place. Try:

If DLookup("[User_Type]", "[tblVersion]", _
"[UserID] = '" & Environ("username") & "'") = "Admin" Then
TitleMSP.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True

If Not IsNull(Me.TitleMSP) Then
TitleMSP.Visible = True
ContactUserID.Visible = True
ContactStatus.Visible = True
Label95.Visible = False
Label97.Visible = True
Label96.Visible = True
End If

Else

TitleMSP.Visible = False
ContactUserID.Visible = False
ContactStatus.Visible = False
Label97.Visible = False
Label96.Visible = False
Label95.Visible = True

End If

Incidentally, I always cringe when people use Environ("Username") to get the
current user, because it's trivial to reset its value for the duration of
your use of the Access application. You'd be much better off using the
GetUserName API call, as illustrated in
[URL="http://www.mvps.org/access/api/api0008.htm"]http://www.mvps.org/access/api/api0008.htm[/URL] at "The Access Web"
 >> Stay informed about: if statement not working 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
IIf statement in update query - Is it possible to use an Iif statement to on the Update to row in an update query?

SUBFORM was working and now it's not - Hi, My subform (order details) in a purchase order has been working and now is not. I have not made any changes to either form or subform... so I'm baffled as to why it would suddenly stop working. What it is doing (or more accurately not doing): ...

Counting Working Days - Basically I have created a combo box called "Priority" with two fields - one is text, the other is a number. The data goes like this Text field "High - within 14 working Days" the number field is (obviously) "14" Text fi...

Switchboard Me.FilterOn not working in 2007 Full Version - Thanks for your time, first off! Situation is this: A 2002 database in place for years with a stock Switchboard - no tweaks, nothing out of the ordinary. Compiled FE works fine for 2002 runtime and full version. A User moved to 2007 and the client is...

Microsoft Office - Can you update Microsoft office version 2003 to 2007 or do you have to buy the newer version
   Windows Help (Home) -> Microsoft Access All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]