Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012

    Unanswered: If Then Statement, if null then get username

    I have a form with a username field. If that field is blank, then I want to pull the username automatically using Environ=("UserName"). However, I don't want the username to save over the original username with the record.

    I have a new entry form that automatically saves the username it gets using environ but I also have a form that looks up current records and allows you to make edits. I want that form to pull the username if there is one, but get it with environ if there isn't

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    This type of thing?

    If Len(Me.UserNameField & vbNullString) = 0 Then
      Me.UserNameField = Environ("UserName")
    End If

  3. #3
    Join Date
    May 2012
    Yea, that's about what I'm looking for! I haven't tested it though so I'll let you know if it works! Just out of curiosity, what does the "len" stand for or what does it do?

  4. #4
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Len(), in this context, returns the Length or number of characters in a String.

    The first step, in Access, to finding out what something means or does, should always be to simply find a place where it appears, such as in the code module where you have the posted code, place your cursor anywhere in the middle of whatever, Len, in this case, and hit <F1> to pull up Help on the given subject.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts