Listbox showing id not value

Directlinq

Registered User.
Local time
Today, 11:20
Joined
Sep 13, 2009
Messages
67
Hi could anybody help me with this please?
I have a table called companynames which consists of companyID and CompanyName.
I also have a table called invoice which is linked to a form . When i type in the invoice form it adds the data to the invoice table. On the invoice form is a combobox which grabs the data from the companynames table. When i select a company name in the invoice form and save it, the invoice table shows the company name as its CompanyID. I then have another form with a listbox showning certain values from the invoice table including the companyname. The problem is the companyname is showing up as its id but i want the name to be showing.
Is There anything i can do about this?
Sorry for being long winded.
Im a newbie so go easy.

Many Thanks
 
I am guessing that your invoice table has the CompanyID field as a foreign key. I am also assuming that your form is based solely on the invoice table. This would explain why you are unable to see the CompanyName field in your form, it doesn't exist in the table you are using for the form.

You should create a query, linking the 2 tables and then base your form on this query.
 
You are correct.

I have created a query linking the 2 tabels which shows me the company name not the companyid. Great, but when i do a notinlist for the combo box to add the new entry if not in the table it does not work.
here is my notinlist code

Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg As String
On Error GoTo CompanyName_NotInList
        ' Open a recordset using the
        ' Activities table.
        Set db = CurrentDb
        Set rs = db.OpenRecordset( _
            "CompanyNames", dbOpenDynaset)
        ' Create a new record.
        rs.AddNew
        ' Assign the NewData argument to
        ' the ActivityName field.
        rs![CompanyName] = NewData
        ' Save the record.
        rs.update
        ' Set Response argument to indicate
        ' that new data is being added.
        Response = acDataErrAdded
Exit_CompanyName_NotInList:
       Exit Sub
Err_CompanyName_NotInList:
       ' An unexpected error occurred, _
       ' display the normal error message.
       MsgBox Err.Description
       ' Set the Response argument to suppress
       ' an error message and undo changes.
       Response = acDataErrContinue

here is my row source for the combo box
Code:
SELECT [CompanyNames Query].[CompanyNames.CompanyName], [CompanyNames Query].CompanyID FROM [CompanyNames Query];

If you need any more infor to help me let me know.
So many thanks
 
You might find it easier to change the "Limit to list" property of the combo box to "No"
 
Your query for the rowsource is backwards of normal. Normally you select the ID first and then the name. So, the quick fix is change these properties:

bound column - 2
column widths - 2";0"

That should display what you want.
 

Users who are viewing this thread

Back
Top Bottom