423,335 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,335 IT Pros & Developers. It's quick & easy.

Environ("USERNAME") first record

P: 1
HI
IM making project by simple "open the form base on your computer name"
I'm recovering the user name of the computer but my problem is it only work if the user in the first record

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Command2_Click()
  2.  
  3. Dim CHECKINGMEEE As String
  4. Dim ashift As String
  5.  
  6. CHECKINGMEEE = Environ("USERNAME")
  7.  
  8. ashift = DLookup("[User Name]", "a shift NAME")
  9.  
  10. bshift = DLookup("[User Name]", "b shift NAME")
  11.  
  12. cshift = DLookup("[User Name]", "c shift NAME")
  13.  
  14. dshift = DLookup("[User Name]", "d shift NAME")
  15.  
  16. If CHECKINGMEEE = ashift Then
  17.  
  18. DoCmd.OpenForm "A shift HISTRY"
  19.  
  20. ElseIf bshift = CHECKINGMEEE Then
  21.  
  22. DoCmd.OpenForm "B shift HISTRY"
  23.  
  24. ElseIf cshift = CHECKINGMEEE Then
  25.  
  26. DoCmd.OpenForm "C shift HISTRY"
  27.  
  28. ElseIf dshift = CHECKINGMEEE Then
  29.  
  30. DoCmd.OpenForm "D shift HISTRY"
  31.  
  32. Else
  33.  
  34. DoCmd.OpenForm "ANYTHING"
  35.  
  36. End If
  37.  
  38. DoCmd.Close acForm, "ENTER FACE"
  39.  
  40. End Sub
Apr 11 '18 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 2,537
boyaqoub,

Welcome to Bytes!

First, we would love to help, but you have not provided a lot of information for us. I can make some assumptions about your database and its table structures, but those would only be guesses (even though, based upon my experience with folks who are newer to Access, many of my guesses would be correct). Based upon how I think you have your tables set up, I may have some structural changes to recommend and a very simple solution. However, if my presumptions are incorrect, those recommendations would be meaningless and unhelpful to you.

Please review this article on Asking Good Questions, and if you have additional clarification, we would be glad to chime in.

Also, there is a rather lengthy article on How to Create User Permissions in a Database. This may be above your skill level at this time, but it may help you see some very viable opportunities for your current database.

Please know that we are not "blowing you off". We want to help--but we need additional information from you in order to provide a viable solution without wasting our time by guessing what you need.

Hope this hepps!
Apr 11 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.