Solved

Link subform to listbox

Posted on 2011-03-13
4
590 Views
Last Modified: 2012-05-11
Hi Experts,

I have a form that has a listbox and subform. the subform is linked to the listbox. it works but the issue I am having is that the subform does not display the data unless I click on the listbox record. The listbox display one records each time the form is opened. but somhow, the record showing in the list box is not selected till I manulay click on it. I am not sure if there is a way that when the form loads, the record in the list box to be slected.

The listbox name is OrgGlID
subform is GLDetails_subform
0
Comment
Question by:HappyAlways
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Khalid Mehmood Awan
ID: 35125374
you should select the desired value available in listbox on subform by adding code lines in ON_LOAD function of sub form.

You will get the on_load function by double clicking the subform in design view.
if you are retrieving the values from a database, select them in the same ON_LOAD function.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 35126852
Use the OnCurrent event of the form to read and set to top value from the listbox:
Private Sub Form_Current()

  With Me!YourListBox
    .Value = Abs(.ItemData(.ColumnHeads))
  End With
  
End Sub

Open in new window

/gustav
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 35130441
Cactus,

Don't you mean:

    .Value = .ItemData(abs(.ColumnHeads))


.ColumnHeads should return a 0 or -1
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 35130528
Of course! Thanks.

/gustav
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question