Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use column 2 from a listbox as criteria for a query?

Status
Not open for further replies.

accessilliterate

Technical User
Sep 30, 2001
13
0
0
GB
Hi

I need to use the value or data from column 2 relating to which ever row is
selected by the user within a list box on a subform as criteria for a query.

I have the following in an Access2000 database.

Main form = frmMainDataEntry
sub form = frmTrackInfoMain
List box = TracksFound

I have tried placing the following in the querys criteria box:
[Forms]![frmMainDataEntry]![frmTrackInfoMain]![TracksFound].Column(2,[Forms]
![frmMainDataEntry]![frmTrackInfoMain]![TracksFound].[ListIndex])
but that didn't work, so I tried:

[Forms]![frmMainDataEntry]![form]![frmTrackInfoMain]![TracksFound].Column(2,
[Forms]![frmMainDataEntry]![form]![frmTrackInfoMain]![TracksFound].[ListInde
x])
That also didn't work, so I tried:

[Forms]![frmTrackInfoMain]![TracksFound].Column(2,[Forms]![frmTrackInfoMain]
![TracksFound].[ListIndex])
same thing, it didnt work:

also access keeps adding brackets as shown below ?????
[Forms]![frmTrackInfoMain]![TracksFound].Column(((((((2,[Forms]![frmTrackInf
oMain]![TracksFound].[ListIndex])))))))

Each time access2k gives the same error message which is = Undefined
function '[Forms]![frmTrackInfoMain]![TracksFound].Column' in expression or
'[Forms]![frmMainDataEntry]![form]![frmTrackInfoMain]![TracksFound].Column'
in expression

Any suggestions please as this is driving me mad.

My gratefull thanks in advance.




 
Try:
Code:
[Forms]![frmTrackInfoMain]![TracksFound].Column(1)
with the 1 meaning column 2 (zero relative)....
 
hi CosmoKramer,

Thanks for the suggestion but no luck, just get the error message:

Undefined function '[Forms]![frmTrackInfoMain]TracksFound].Column' in expression.

Any suggestions please ??



 
Hi!
It's been a while since I programmed this stuff so I'm not sure I remember correctly, but try this if this is not what you are already trying to do. I think that in order to access the subform you have to refer to the .Form property of the main form.
So replace
Code:
[Forms]![frmMainDataEntry]![frmTrackInfoMain]![TracksFound].Column(2,[Forms]
![frmMainDataEntry]![frmTrackInfoMain]![TracksFound].[ListIndex])
with
Code:
[Forms]![frmMainDataEntry]![<subFormControlName>].Form![TracksFound].Column(2)
or something like that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top