Solved

Link subform to listbox

Posted on 2011-03-13
4
588 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now