Concatenate FindUserName() with domain name (1 Viewer)

Eljefegeneo

Still trying to learn
Local time
Yesterday, 18:50
Joined
Jan 10, 2011
Messages
904
I must be missing something, but I cannot get the user name which is from the function FindUserName() to concatenate with a domain name. For example. My FindUserName() is Gene. But if I try to concatenate using FindUsername() & "@yahoo.com", all I get is Gene. If I do it backwards, that is, "@yahoo.com" & FindUsername, I get @yahoo.comGene. I've tried using a second unbound control to get the "FindUserName()" and then concatenate that control with the domain name, but it still won't work.
What I am trying to accomplish is a simple SendToOutlookTask using this field as the default email address to which the task should be assigned.
To me, the mostly novice VBA user, it should work, and would seem to be the simplest way of setting the field default value. There are probably other ways of doing the same thing, but I am stubborn and want to either figure this out or find out why it is not working. Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:50
Joined
Aug 30, 2003
Messages
36,132
What exactly is the code that isn't working?
 

Eljefegeneo

Still trying to learn
Local time
Yesterday, 18:50
Joined
Jan 10, 2011
Messages
904
FindUserName() give the correct result. When I try the concatenation FindUserName() & "@yahoo.com", I just get the user name, not the full concatenation with the domain (@yahoo.com). That is Gene and not Gene@yahoo.com. It works backwards, that is, "@yahoo.com" & FindUserName(), @yahoo.comGene, but not the other way.

FindUserName() is a function that I found on this forum a long time ago and have used for various thinks.
 

DrallocD

Registered User.
Local time
Yesterday, 21:50
Joined
Jul 16, 2012
Messages
112
It may be a bug in FindUserName(). This could happen if it is not trimming the result correctly.

Can you post your the FindUserName() code?
 

Eljefegeneo

Still trying to learn
Local time
Yesterday, 18:50
Joined
Jan 10, 2011
Messages
904
Attached is a sample DB.

I came to the realization after many hours, that I was working on a wrong assumption. I really don't need to have the User concatenated with the domain name, since the code for sending it to a task prevents one from sending an email to oneself. However, I would like to know how to concatenate the FindUserName with a domain name or any other text. It works fine backwards, domain name (or other text) & FindUserName, but not the other way.

Thanks for taking a look at it.
 

Attachments

  • TaskDB.accdb
    476 KB · Views: 98

GinaWhipp

AWF VIP
Local time
Yesterday, 21:50
Joined
Jun 21, 2011
Messages
5,899
Well, that took a minute until I realized it wasn't the Form that had the problem but the Module. In your Module change this line...

Code:
FindUserName = Left(strBuffer, lngSize)
to
Code:
FindUserName = Left(strBuffer, lngSize - 1)

Why? There was an extra character at the end that caused the issue. Should work fine once you adjust that line.
 

GinaWhipp

AWF VIP
Local time
Yesterday, 21:50
Joined
Jun 21, 2011
Messages
5,899
As a side note... You really should create a PK like TaskID which you can make Autonumber. It will come in handy if you ever want to relate this table to another table.
 

Eljefegeneo

Still trying to learn
Local time
Yesterday, 18:50
Joined
Jan 10, 2011
Messages
904
Thanks. Works!! I shall change the code in my main DB so that it reflects this change. And yes, I should probably have a PK, just hadn't gotten that far.
 

Users who are viewing this thread

Top Bottom