Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67

    Will DLookup do me any good?

    Hi guys!

    I need some help - when a form loads I need it to look up a role name in a separate table and if the field RoleName = "Dividends/Commissions" I want the form to make visible certain fields that do not need to be visible to others.

    I have a function to call the Windows Environ Username which is how the RoleName would be looked up as the two tables are linked via the Username and each Username is assigned a RoleName.

    I hope that makes sense and I really hope that someone can give me a hand!


    Thank you!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    It's something you can test fairly easily -- did you try anything?
    You could try the form Open event also.

    Have you tried google?

    Here's on post I found
    http://www.utteraccess.com/forum/Con...-t1942572.html

  3. #3
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    yeah I did try Google - Unfortunately for some reason DLookup just doesn't click for me - I need an idiot's guide :-P

    The link you had posted is great - unfortunately if I try to link my two tables in my query and add the field to the form I can't edit any data which is why I was thinking possibly a DLookup

  4. #4
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    My first venture into DLookups and I think I'm halfway there. I added a text box to my form then in the on activate of the form properties I put; Me.Text27.Value = DLookup("RoleName", "tblRole")

    For my Username in the table my RoleName should be Classic however it's showing as something entirely different any suggestions?

  5. #5
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    Sometimes I just need you guys to help me talk it out!

    I built a query linking my master table and the role table - then did the DLookup from the Query - that did it :-D

    THANK YOU for your help

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

  7. #7
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    I hope someone can still help! Now I'm having an issue - I need to make some of the fields visible based on the value of the Role field. I have tried a few ways and it doesn't like the way I'm doing it. Here is the code to fill in the field;

    Me.Text41.Value = DLookup("RoleName", "qryRole") - this is on the form's OnCurrent event

    I have tried putting these two lines of code in both the onCurrent of the form and the after update of the text41 field;

    Me![Bank Modified Date].Visible = (Me!Text41 = "Dividends/Commissions")

    If Me.[text41]="Dividends/Commissions" then
    Me.[Bank Modified Date].Visible = True
    Else: Me.[Bank Modified Date].Visible=False
    End if

    Does anyone have any suggestions?

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Something along these lines (not tested)
    If DLookup("RoleName", "qryRole", "RoleName='" & "Dividends/Commissions" &"'" Then
    me.xxx.visible = True
    else
    me.xxx.visible = False
    End If
    Last edited by orange; 01-09-2013 at 11:00 AM. Reason: spelling

  9. #9
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    Thanks Orange - I'm still getting no result, at first I had a syntax error but changed the " " around Dividend/Commissions to ' ' I have included the changed code below however I am still yielding no results.

    Private Sub Form_Current()
    If DLookup("RoleName", "qryRole", "RoleName='Dividends/Commissions'") Then
    Me.[Bank Modified Date].Visible = False
    Else: Me.[Bank Modified Date].Visible = True
    End If
    End Sub

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Can you post a zip copy of your database?

    You could also try

    Do a Ctrl G to get to your immediate window,
    then type a ?
    then your Dlookup, and see what you get printed.

    I have tried in my sample where EmployeeInOffice is a query, and Sam was a FName. If Fname is not found, it returns Null

    ?dlookup("FName","EmployeeInOffice","FName='Sam'")
    Sam
    Last edited by orange; 01-09-2013 at 12:46 PM. Reason: spelling

  11. #11
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    I have tried to post a zip copy before and again just now - I click upload it gets to 100% and then no files show to attach.....I know - I'm a problem child all 'round.

    I'm at such a loss!

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Did you make a zip file ?
    Go to the Go Advanced------------------------------------------------------------------------------------------------------------below here
    then Manage Attachments
    Browse to your zip file, click Add Files

  13. #13
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    Yes it is a zip file - the screen that pops up "Manage Attachments" I click Add Files then browse my zip file then click Upload. In the bottom left corner it gives me an upload status, I assume when the status has hit 100% the file should show in the "Home" window to be attached but nothing shows.

    I have tried it in Google Chrome - IE and Opera - I get the same result.

    I was wondering if maybe my browser was being tempermental

  14. #14
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    I'm beginning to wonder if a compact and repair is in order.

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Reference, a good one
    By snoopy in forum Programming
    Replies: 3
    Last Post: 07-26-2012, 10:03 PM
  2. Is this a good database design?
    By Someday in forum Database Design
    Replies: 4
    Last Post: 07-22-2012, 06:50 PM
  3. Replies: 1
    Last Post: 06-06-2010, 12:29 PM
  4. SQL - Read any good books lately?
    By metaDM in forum Queries
    Replies: 2
    Last Post: 03-05-2009, 12:46 PM
  5. Creating a *Good* Custom Message Box
    By Jerimiah33 in forum Forms
    Replies: 1
    Last Post: 11-09-2005, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums