Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a value in a lookup combobox from another form

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
US
I have a form with a subform that includes a combobox that lookups a value like:
Code:
SELECT ID, Name FROM Table1
The bound column is 1 and the widths are 0;1

From this form the user can open another form and choose values that could be placed in Table1. The code looks like this:
Code:
With CurrentDb.OpenRecordset("Table1", dbOpenDynaset)
        For iRow = 0 To lbx.ListCount - 1
          If Me.lbx.Selected(iRow) Then
            .AddNew
            ![ID] = Me.lbx.Column(0, iRow)
            ![Name] = Me.lbx.Column(1, iRow)
            .Update
          End If
        Next iRow
End With
Forms!frm.Form("chd").Requery
Exit Sub

As you can see the user can choose from a listbox (lbx) and it will insert a record in Table1. The form "frm" and its subform named "chd" is requeried.

The Problem: The subform's combobox does not display the name even though the table1 id and name appear in the table.

Does anyone know how to display the value (field name is "Name") in this field rather than blank?

Thanks,
Rewdee

 
Not sure I understand correctly.
If it's not being included in the combobox, you need to requery the combobox.
<combobox>.Requery

To display the name:
<combobox> = <value>
 
To display what I'm talking about see the images below:

First form user can choose a class from with combobox:
MainCourse.jpg


User can use find form:
Find.jpg


User makes a selection (runs code previously listed) BUT the combobox does not display CourseDescription even though the value is in the underlying table.
MainCourse2.jpg


I've tried requerying both the combobox and form to no avail.

Thanks,
Rewdee
 
Is there a &quot;dope&quot; posting similiar to &quot;mark this thread as helpful&quot; because I certainly earned one on this posting. The problem was I trying to insert an Account Code number in a ClassCode field and hence the problem of why it the description does not show up.

Thanks All,
Rewdee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top