Results 1 to 6 of 6

Thread: How to use a datacombo in outlook

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    How to use a datacombo in outlook

    I want to populate a combo box with all the accounts from a db. I want the account name to show but I want to be able to recover the account id when a user makes a selection.

    In Vb I'd do this by using a datacombo, setting it's datasource to a adodb object and setting it's listID to accountName and it's bound column to accountID. Easy.

    The trouble is that the datacombo in outlook doesn't seem to have a datasource property (The datagrid didn't have one in it's properties panel either but I was able to set it from code - sadly not the case with the datacombo). So how do you set the datasource for a datacombo in outlook?

    Alternatively, is there a way I could use the standard combobox in outlook? I would want it to display the account name without the account id but I'd want ot be able to recover the account id when a user makes a selection.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to use a datacombo in outlook

    You can use a standard combo box. It has a ItemData property that takes a numeric value, one for each Item. So if they select
    the 5th item the you can get the .ListIndex property which will be 4 and the .ItemData of that will contain the ID info.

    When you populate the combo also populate the .ItemData too.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: How to use a datacombo in outlook

    I looked at the itemdata property but it's not suitable because the id field isn't numeric. As a stop-gap I've set up an id's collection and I'm using the itemdata property of the combobox listitem to store the index of the id in the ids collection but it's all getting a bit messy.

    Edit: Actually that's not what I've done (that's the trouble with checking on forums before reminding yourself what you did last thing lastnight ). The outlook combo doesn't have an itemdata property so I'm actually using the listindex of the combo box as the key when I insert into the id's collection. Like I said though , it's getting messy

    All told the controls in outlook seem to differ quite substantially from their standard vb counterparts and not for the better.
    Last edited by FunkyDexter; Jun 9th, 2005 at 03:43 AM.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to use a datacombo in outlook

    Sorry about that.

    Another thing you can do is use a second hidden conbo box to hold the alphanumeric id data. The two combos can be easily synced in code
    so when the visible one is selected the corresponding hidden combo is changed as well.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: How to use a datacombo in outlook

    I think that's similar to my idea of keeping a collection of id's keyed by the combobox's index isn't it? Ultimately I'd still just be maintaining two collection/list/array thingies and trying to keep them synched. Or is there some extra functionality that the combo would give me that would help?

    Anyway, I've got it working using the id's collection and I understand the code... pity the poor sucker who'll have to maintain it when I'm gone though.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to use a datacombo in outlook

    Think of it as job security for the next guy.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width