if statement not working

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
0
Utf
2/1/2010 5:40:01 PM
access 16762 articles. 3 followers. Follow

3 Replies
772 Views

Similar Articles

[PageSpeed] 46

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


-- 
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"deb" <deb@discussions.microsoft.com> wrote in message 
news:498C296B-CFBC-4695-98A6-E8E43AFB2504@microsoft.com...
> 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 


0
Douglas
2/1/2010 5:50:21 PM
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 
http://www.mvps.org/access/api/api0008.htm at "The Access Web"

-- 
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"deb" <deb@discussions.microsoft.com> wrote in message 
news:498C296B-CFBC-4695-98A6-E8E43AFB2504@microsoft.com...
> 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 


0
Douglas
2/1/2010 5:54:35 PM
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
0
Utf
2/1/2010 6:21:01 PM
Reply:

Similar Artilces:

Unicode does not always work in outlook 2007?
Using outlook 2007, when I receive an email with a chinese subject line, it displays the chinese as jibberish in the subject column in the inbox view. However when I open the message then it displays the chinese correctly on the subject line. In the contacts list, when I try to create a new contact with chinese name by copy and paste, the name displays as ????. But if I paste the same name into the notes section, then it displays the chinese correctly. Is this a bug or is it by design? Does it work better in office 2010? ...

Email of Statements
Can you use another pdf Writer other than Adobe for this feature No, you must use Adobe to use this particular feature. Kind of odd, isn't it? -- Charles Allen, MVP "rcr" wrote: > Can you use another pdf Writer other than Adobe for this feature yes and no. When print to pdf was added - 6.0 i think - there weren't many other options for creating pdf's. OK, now there are. But OK which ones do we add support for? Them all? Support for PDF output must support being able to automatically name the created output file without intervention. And I assume many bu...

vlookup from two sources
[Excel 2003] Is it possible to use syntax to perform a vlookup from a source and then another if the first is False? For example, My primary table of data is called "Materials" and my second source is a range A81:E140 on the same sheet as the vlookup, So something like : =vlookup(A1,Materials,2,vlookup(A1,A81:E140),2,False) Can anyone help with advice on syntax? Thankyou, Roger the false in a Vlookup is the mtach type, not an value to use if the formula is false. =if(iserror(vlookup(A1,Materials,2,false)),Vlookup(A1,A81:E140,2,false),Vlookup(A1,Mate...

How to transparent editbox control works correctly...
Hi i am working on an application where i have dialog based application. On dialog there is a picture control which displays a picture. Now i want to put an edit box. Text box string is current time which i am getting from OnTimer handler. i want that editbox control should be transparent except text in it. for this i have work with following code and get succeed in OnCtlHandler of dialog if(pWnd->GetDlgCtrlID() == IDC_EDT_Isha) { pDC->SetBkMode(TRANSPARENT); hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } it makes the backgound tranparent but when the value of the edit box change...

Using lookup instead of if-statements, how?
Aloha, Here is screen where I try to explain my problem: http://hem.bredband.net/maromb/example.html On sheet 1 I have a ranking list of with diffrent cities, haulier an differnt cost/weight. Sheet1 Weight A | B | C | D | City | Haulier | 0-2,5 | 5-7| 7-10... ____________________________ City1|Haulier1 | 100 | 95| 80 City1|Haulier2 | 110 | 100| 90 City1|Haulier3 | 120 | 110| 91 City2|Haulier1 | 95 | 90| 87 City2|Haulier2 | 105 | 100| 89 City2|Haulier3 | 107 | 105| 88 On sheet2 I have made a VBA User ...

Autofilter not working properly
When a column is autofiltered for blanks or nonblanks, the next available row for data entry is wrong ie: the last populated row is 300, but the row immediately below the filtered area is something like 3275 (random figure). Any ideas please, as this is driving me mad Hi, Does this problem happen when you highlite the range, then turn on autofilter? If not, you may have cells which at one time had data in them and Excel needs to reset the last cell. Have a look at: Last Cell - Resetting http://www.mvps.org/dmcritchie/excel/lastcell.htm You may have cells which at one time had dat...

Connector to Lotus Notes not working
I did a quick search but I think my problem specifically hasn't been covered. I have Outlook 2003, SP2 as a standalone client (no exchange). I'm trying to connect to Lotus Notes (version 6.5.4 on my desktop) but I'm getting an error after adding it in as an email account: The set of folders could not be opened. The server is not available. Please contact your system admin. This worked a month ago, but in that time, I got a new machine, so I had to re-install the connector. Please help! Any ideas? HI ricochet, if you have solved your problem do let us know. I have precisely...

POS
Hi I know POS can't accept deposits nor layaways. My question is, has anyone figured out a procedural workaround for this? -Luis TIA Hello Luis, I am in the same boat as you are. I have a brand new "unsable" POS because there is no way to have a lay away... Is there a work around or should I stay with my old POS? -- Fabien in seattle "Luis" wrote: > Hi I know POS can't accept deposits nor layaways. My question is, has anyone > figured out a procedural workaround for this? > > -Luis > > TIA Citi Provides gift cards that can be used as...

Selection Criteria for Statements
When printing statements, no matter what type of seleciton criteria we enter (ie, print only statements for customers with balance > 0) all statements print. Any ideas ? Store Operations 1.2 SP1 ...

My password don't work on my MS Money 2004 Business edition
Hi everyone, I am panicing.My Microsoft Money Small Business Edition password is not working. Somehow my password changed. All my business data and personal financial data is on there and i don't know what to do. About two days my password does not work. I did not change anything. I wanted to print an invoice and it wouldn't allow me to. It would not allow me to go further without a password. Is there a solution to this problem or I am just doomed. Please do a search... if you did a very little superficial search, you will notice MANY people having the same problem. >-----Or...

Money 2003 statement download problems
I used Money 2003 with no issues for over a year. It's always been cranky, but now it is no longer automatically downloading bank statements. The information for the accounts is correct and it can connect me to the web pages just fine. IN some cases, Money also does not show new information when I download the ActiveStatement Money file manually from a bank webpage. Also, every time I do manage to download a file, Money crashes when opening it and needs to be restarted. Ideas or suggestions? I swear if I have to buy a new version, it won't be a MS product. Maybe the onl...

"Show Placeholders" in options/view menu does'nt work.
I have a macro that places a large number of pictures on a spreadsheet. I would like the pictures to show as "placeholders" to speed up viewing/editing. The only problem is that this feature (under Tools/Options/View) does not work. All the images are being display normally. I have tried this in Excel 2000/2003/XP with the same result. This feature works great in MS Word. Please help. To see what I'm talking about. Go to Tools/Options/View and check the "Show Placeholders" option. Now insert a picture or clipart. The image will be displayed normally instead of just a b...

Ctrl-c fails to work
Unusual issue. I don't know if anyone knows a workaround. When a user opens GP (v7.5 sp4 and 7), ctrl-c and ctrl-v work fine for copying and pasting. Once Transactions>>Financial>>Reconcile is opened, ctrl-c no longer works. You can click edit>>copy, but the keyboard shortcut to copy fails (ctrl-v still works). Closing GP and reopening resolves the issue, until you open that window again. Any thoughts? I have a client that has the same issue that the Ctrl-C will fails to work on the SOP item line. However have not yet been able to determine what conditions cause i...

Nested IF statement #2
Excel only allows 7 nested If statements, is there a way around this? -- jgannon ------------------------------------------------------------------------ jgannon's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29003 View this thread: http://www.excelforum.com/showthread.php?threadid=487455 Without more information, (Like exactly what are you trying to do that you need more than seven nested if statements?) I can't help you. BUT you might try spreading out your function over more than one column, such that the output of one function gives an incomplet...

Ignore option under Library Monitoring does not work
I have read the posts about this issue but I'm still having a problem with the auto-monitoring for folders to use in the Library. Like others, I want to create a new Library on another drive. I have set that folder (I:\Music for example) to be the Rip folder and have added it to the monitor list. I have set all the C:\... folders to IGNORE and clicked OK. All my old music still shows up. I can not re-rip the music to the new folder since WMP thinks it is already in the Lirary. I don't want to delete the old Library either. On Tue, 6 Apr 2010 14:19:01 -0700, bigsky88 &...

.NET access not working
Hey everyone. I can get into hotmail and my MSN account information but not money using my .NET name and password! This is VERY wierd. Has this happened to anyone?! I am using Money 2003. Any help is very appreciated! Jose I have exactly the same experience with money 2004. It started last week and I'm pretty tired of it. Mark >-----Original Message----- >Hey everyone. > >I can get into hotmail and my MSN account information but >not money using my .NET name and password! This is VERY >wierd. Has this happened to anyone?! I am using Money >2003. A...

If statement with 9 sequences.. problem
Hello everybody, I currently have an IF statement w/8 sequences and it is working properly. I'm doing this for tax purposes. When I try to add one more sequence, it doesn't work. basically I just want to say If B4<529,0. I want it to return a value of zero if cell B4 is < 529. This is my current formula: =IF(B15<943,(B15-529)*0.1,IF(B15<2914,(B15-942)*0.15,IF(B15<3618,(B15-2913)*0.25,IF(B15<4772,(B15-3617)*0.27,IF(B15<5580,(B15-4771)*0.25,IF(B15<8347,(B15-5579)*0.28,IF(B15<14670,(B15-8346)*0.33,IF(B15>14669,(B15-14669)*0.35,0)))))))) P...

Trace dependents not working
I am able to do trace precendents from cells in several sheets to cell A. But when I tried to do a trace dependent on cell A, the trace dependent could not fine any formulas that refers to the active cell A. ...

Money 2007 Update Utility Not Working
Everytime I start Money 2007 I have a pop up window asking me to update Money and press OK. Which I do, and it closes Money and downloads the update. It then asks if it's ready to install, and that crashes. Then it says 'Microsoft Money Update Utility has caused an error and needs to be restarted.' or whatever that message is. That happens everytime I start Money, and I'd like to update it, because that notification is real annoying. What is wrong ? Is there a way to manually update Money 2007 ? Thanks Uninstall the IE 7 beta and do the update. The crash will stop. ...

why doesnt ar account age if it is marked no statement
what does aging have to do with if a customer's statement? ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=193905fd-c73a-4c65-a9b0-6410e0795658&dg=microsoft.public.g...

archive not working
We are having company wide archiving issues. We are on Exchange 2003 SP2 and users are mixed Office XP and Office 2003. I have posted the question before on this and it looks like there is an issue with modify date. I am not sure if this will help with modify date, but we are using VERITAS as our backup and Exchange agent that will log in to every mailbox and backup email by email. Does the agent modify the emails date then? Before I take it to the Microsoft support and spend money, can someone help explain why this is going on and why can't we archive. No error messages are generat...

Subtotaling on column with IF statement results
I created a spreadsheet with one column having an IF statement - it calculates how much we should re-order per store based on what was sold. I asked it to subtotal for each store - the formula appears in the cell, but it does not calculate the subtotal. I tried saving the column as the values, but it still does not subtotal. When I typed in the numbers, it DID subtotal. What do I need to do so it will subtotal? Thanks for your help. -- STK By any chance are you importing the data from another application? Check out your numbers: does the cell contain an apostrophe and then the numb...

Advanced Search No Longer Works
Has anyone run into this situation where the user clicks on the "Advanced Search" button and nothing happens. Usually it would allow the user to do Advanced Search options, but no longer. The end stated that this problem just started happening a week ago. She said nothing new has been added to the computer. It doesn't appear to be greyed out, but no longer allows the option for Advanced Search. I appreciate any suggestions. Thanks. There seemed to be a couple of potential problems which resolved this problem. First, I added the IP Address of our CRM server wi...

Messages sent only to me in blue setting not working
For some reason this setting no longer works after we moved to new PCs at our company. Strange because it works for some memebers of our group and not others. Any suggestions would be appreciated. We have absolutely no idea what you are talking about: Please provide: Version of Office/Outlook Where this "mail sent to me" setting? Is this done via a rule? Have you checked your settings against those of people where it does work? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all...

Reading my home email while I'm at work
I have Outlook Express 6 on my computer at home and at work. Is there a way I can check my home email from my office computer? Try posting this in an Outlook Express news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Outlook Express is a part of Internet Explorer and has its own news groups. You can also find some good Outlook Express information here: http://insideoe.tomsterdam.com --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, a...