tricks of gurus

Paul,

If you ever get stuck on treeview stuff, let me know. I did quite a bit with one in a project last year. Like you said, a very neat control, but can also be a bit frustrating if you're a self-edumacated programmer like myself and having to bootstrap it.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Actually, found this little article on Colo's page, which was VERY useful. I had also purchased the 3-volume Microsoft Visual Basic 6.0 Reference Library a few years ago, and used the second volume for the first time as I tried to get my brain around the TreeView control. Between the 2 resources, I think I have a pretty good handle on it.

And yes, I also don't have a diplomica that says 'Puter Programming on it. But I have gotten pretty good at boot-strapping it.
 
Oh, neat link. Thanks. Won't have time to really study it and play any time soon, but someday... someday...
 
OK Here's one. I was making a change password form for Access and I noticed that it was displaying the username all funky-like. I wanted to display the username in the actual case of the username (yes I know the username is not case-sensitive) and it was displaying all lower case. And that was when I noticed that Access.CurrentUser returns the username that the user logged in with. So if they logged in with all caps, you get the username in all caps. However Access.DBEngine.Workspaces(0).UserName will return the username in the case that it was assigned in. Not a huge deal but useful to know to avoid having to worry about case conversion etc. (Not mention it displays prettier too.)
 
Okay, so how does that translate into Excel? I use environ("username"), and just got burned by a case discrepency... changed to strcomp(), but might be nice to have an alternative.
 
I use Environ("username") too. Very simple, but in Access 2003 it's a pain because of the Sandbox mode that MS introduced for security.

Aaron's approach of listing the current user works if you use user-level security in Access. AFAIK it doesn't translate to Excel

Denis
 
Hi Hatman,
It is somewhat limited in application, but it was just one of those things that bugged me because the usernames were assigned like this: JDoe FSmith, etc. There is no case conversion that will make them display properly if the user changed case when they logged in. But since it was bugging me and I eventually found the solution, I thought I would post it up.
As far as Excel goes, there are actually half a dozen dlls that will grab the username in some way... A few of those methods are described here: http://www.vbaexpress.com/kb/getarticle.php?kb_id=768 (They did not mention the DAO method but I think this is more Excel targeted.) I am not sure, but I suspect most dlls are just tapping the API call in the first example anyway. So if you were looking for the "right way" you could use the API. The other thing to consider instead of strcomp might be "Option Compare Binary" but remember that will affect the comparisons of the entire module.
 
Rock ON! I'll have to look at that in more depth this afternoon.
 
Hmm not sure if this is a guru trick either but still good to know. In Microsoft Access, if you turn on "Require Variable Declaration" in the VBE, it will put "Option Explicit" underneath "Option Compare Database". Which is a bit of a problem because "Option Explicit" needs to be above "Option Compare Database" to work properly. If you do not correct it when building a module, it could cause some unanticipated results.
 
One I just learned, after using the msgbox() function for many years..

The msgbox() function supports multiple arguments in the Style parameter: use them if it makes your message more meaningful:
Code:
MsgBox "Do you want to try again?", vbMsgBoxHelpButton + vbYesNo + vbCritical, "Oops", ThisWorkbook.Path & "\" & Help_File_Name, 2
 

Forum statistics

Threads
1,225,336
Messages
6,184,345
Members
453,227
Latest member
Slainte

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top