Inserting IDs into a list box using ItemData function

From: Evan (evandelagrammaticas_at_hotmail.com)
Date: 10/06/04


Date: 5 Oct 2004 21:43:54 -0700

Hi guys, I am sorry for the cross-post but I am experiencing a problem
that I just cant seem to sort out and I am beginning to think that for
something as simple as this - there may be no solution.

CURRENT SITUATION:
I have a database with 2 tables in it... the first table is users
(userID, userName) the second table is notes (noteID, userID, notes).
I have managed to populate a list box in a userform (MSWord) with all
the userNames from the user table. I would like to link the user names
to the userID's so I will be able to locate all the notes related to a
specific user from the notes table. The crux of the current code WHICH
WORKS looks like this...
    Do While Not rec.EOF
        With lstCategories
            .AddItem rec("categoryName")
        End With
        rec.MoveNext
    Loop

PROBLEM:
I have done a lot of research and found a function called ItemData
which is supposed to assist me in doing this. According to my research
(which my be applicable to VB only), the solution would look similar
to this:
    Do While Not rec.EOF
        With lstCategories
            .AddItem rec("categoryName")
            .ItemData(.NewIndex) = rec("categoryID") //NEW CODE - NOT
WORKING
        End With
        rec.MoveNext
    Loop

When I execute the code above, I get an error - "Compile Error: Method
or data member not found", it then it proceeds to highlight the
.NewIndex function, even though I belive the error is with the
.ItemData function as that does not seem to be avaliable ?!?!

If there is anyone out there that can help me with this problem I
would greatly appreciate it.

Regards,

Evan



Relevant Pages

  • RE: Exporting to Excel
    ... The OpenQuery call in the Loop seems to be critical. ... Static Function GetUserIdAs String ... 'Open the specific query with the data to be exported ... You can use this to drive a loop that will export a worksheet per userid. ...
    (microsoft.public.access.externaldata)
  • Re: ListBox/ComboBox-to-TextBox question
    ... Just bound the dataset to the ListBox. ... Description, Status, UserName FROM "; ... Password, LoginName, Description, Status, UserName) VALUES (@UserID, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Adding as option in a multiselect list box
    ... A part of this I haven't seen described yet is that you need something in the list box After Update event to allow for UserID being zero. ... UserName FROM tblUsers ORDER BY UserName ...
    (microsoft.public.access.forms)
  • Re: how to get users details
    ... Well Im using email address instead of username for a few reasons, ... is already the memid field there. ... UserID, at least for login purposes, rather than as a separate entity ... ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Conditional display of records ...
    ... So in my query, I will map 'A' and 'B' for flag='Y' and userid (with which ... users logon) with the userid stored in table 'B'. ... The trick is to create a function that calls the username function and pass ... Function CheckFlag(strFlag As String) As Boolean ...
    (microsoft.public.access.formscoding)