Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Link subform to listbox

Posted on 2011-03-13
4
Medium Priority
?
603 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 51

Accepted Solution

by:
Gustav Brock earned 2000 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 48

Expert Comment

by:Dale Fye
ID: 35130441
Cactus,

Don't you mean:

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


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

Expert Comment

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

/gustav
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 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