View Full Version : syntax to reference a combo box on an open form in a query


WinDancer
10-23-2008, 12:57 PM
I am writing a query using a combo box on an open form as a parameter.

the combo box is three fields, name, address, and phone.

I am trying to use forms!ParticipantPicker!combo58.col(0)
to select the name to use in the query

and am getting a syntax error.

This reference works to write a record from a form... so it certainly won't work in a query :)

Can someone post the correct way to reference a combo box column on a form in a query?

Thanks,
Dave

RuralGuy
10-23-2008, 01:04 PM
Forms!ParticipantPicker!Combo58.Column(0)

WinDancer
10-23-2008, 01:08 PM
Getting an undefined function error with that code, too.

RuralGuy
10-23-2008, 01:17 PM
This syntax assumes ParticipantPicker is an open form and a ComboBox on this form is named Combo58. It *is* the correct syntax.

WinDancer
10-23-2008, 01:52 PM
Then I have something else the matter. That is the syntax I thought woukld work, too...

RuralGuy
10-23-2008, 01:55 PM
Do you have any reference (http://www.accessmvp.com/djsteele/AccessReferenceErrors.html) problems?

WinDancer
10-23-2008, 03:21 PM
Not sure why, but I went in to SQL view and tweaked it a little, and it now runs fine :)
SQL+
SELECT tblEnrollment.[Name/Type], tblEnrollment.Cred, tblEnrollment.Specialty, tblEnrollment.Address, tblEnrollment.Phone, tblEnrollment.Sem, tblEnrollment.SemDate, tblEnrollment.SemYear, tblEnrollment.Location, tblEnrollment.Hours, tblEnrollment.Cost, tblEnrollment.Pd, tblEnrollment.AmountPD, tblEnrollment.attend, tblEnrollment.PID, tblEnrollment.RecSource, tblEnrollment.SID
FROM tblEnrollment
WHERE (((tblEnrollment.[Name/Type])=[Forms]![ParticipantPicker]![Combo0]));

Not how I wanted to, but it works :)

Thanks,
Dave