Solved

Link subform to listbox

Posted on 2011-03-13
4
597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50

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 50

Expert Comment

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

/gustav
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

749 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