Solved

How open form to selected record in a listbox

Posted on 2014-01-15
2
2,160 Views
Last Modified: 2014-01-16
I'm trying to open a form (form #2) to a selected record in a listbox in form #1.

Here is my code which doesn't work...

DoCmd.OpenForm "frmPlantedBayQtys", , , "[PlantedBayID] = " & Chr(34) & Me.ListBayQty.Column(1) & Chr(34)

Note that PlantedBayID in numberic.
0
Comment
Question by:SteveL13
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39784210
try this,

DoCmd.OpenForm "frmPlantedBayQtys", , , "[PlantedBayID] = " &  Me.ListBayQty.Column(1)


what values do you get in Me.ListBayQty.Column(1) ?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39784360
Steve,

Are you really interested in the 2nd column of the listbox, or the one that is the bound column?  Listboxes are zero based, so by referring to column(1) you are actually looking at the 2nd column in the Listboxes RowSource.

is the field [PlantedBayID] a number or a string?  if it is a number, Capricorn1's example above should work.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

706 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