Easy Quick Quesiton

  • Thread starter Thread starter MIKE
  • Start date Start date
M

MIKE

Within my code i have a line that reads: Ch1 =
[Ch1].Itemdata. The debugger is telling me that is wrong
and it will not work in the form. What am I missing that I
can not find?
 
MIKE said:
Within my code i have a line that reads: Ch1 =
[Ch1].Itemdata. The debugger is telling me that is wrong
and it will not work in the form. What am I missing that I
can not find?

ItemData is an array (or some other numerically indexed collection;
it's not quite clear), and so must be indexed by the row number. For
example,

Ch1 = [Ch1].ItemData(0)

for the first row in the list.
 
Ok i had that in my code but when I debug my code a pop-up
box comes up and says I have a compile error. Is that
error within the code or how I was setting up my form
-----Original Message-----
Within my code i have a line that reads: Ch1 =
[Ch1].Itemdata. The debugger is telling me that is wrong
and it will not work in the form. What am I missing that I
can not find?

ItemData is an array (or some other numerically indexed collection;
it's not quite clear), and so must be indexed by the row number. For
example,

Ch1 = [Ch1].ItemData(0)

for the first row in the list.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Now that I did that, Now another question. If i have two
combo boxes and when i pick one item in the first combo
box, i automatically want the second combo box to show the
corresponding number. i have the first combo box showing
but nothing comes up in the second box. What am I doing
wrong
-----Original Message-----
Within my code i have a line that reads: Ch1 =
[Ch1].Itemdata. The debugger is telling me that is wrong
and it will not work in the form. What am I missing that I
can not find?

ItemData is an array (or some other numerically indexed collection;
it's not quite clear), and so must be indexed by the row number. For
example,

Ch1 = [Ch1].ItemData(0)

for the first row in the list.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Mike said:
Now that I did that,

Does that mean you've resolved the compile error?
Now another question. If i have two
combo boxes and when i pick one item in the first combo
box, i automatically want the second combo box to show the
corresponding number. i have the first combo box showing
but nothing comes up in the second box. What am I doing
wrong

I'll have to ask a bit more about how you have this set up. If the
value in the second combo box is completely dependent on the first combo
box, then I don't think you should be using a combo box for this second
value at all. Rather, you should be using a text box that shows the
calculated value. If you include that value as an extra column in the
first combo box, then the second combo box can pick it up from that
column via a controlsource expression.

For example, suppose you have a table of Employees like this:

Table: Employees
Field: EmpID
Field: EmpName
Field: EmpSSN

And you have a combo box to pick an employee by name and save the EmpID
in its bound field:

Combo box: cboEmployee
ControlSource: EmpID
RowSource: SELECT EmpID, EmpName, EmpSSN
FROM Employees ORDER BY EmpName;
ColumnCount: 3
BoundColumn: 1
ColumnWidths: 0"; 2"; .5"

Then you could also have text box on the form to show the SSN for the
selected employee:

Text box: txtEmpSSN
ControlSource: =[cboEmployee].[Column](2)

Note that the expression refers to column 2, because in VBA code the
columns of the combo box are numbered starting from 0.
 
-----Original Message-----
Now that I did that,

Does that mean you've resolved the compile error?
Now another question. If i have two
combo boxes and when i pick one item in the first combo
box, i automatically want the second combo box to show the
corresponding number. i have the first combo box showing
but nothing comes up in the second box. What am I doing
wrong

I'll have to ask a bit more about how you have this set up. If the
value in the second combo box is completely dependent on the first combo
box, then I don't think you should be using a combo box for this second
value at all. Rather, you should be using a text box that shows the
calculated value. If you include that value as an extra column in the
first combo box, then the second combo box can pick it up from that
column via a controlsource expression.

For example, suppose you have a table of Employees like this:

Table: Employees
Field: EmpID
Field: EmpName
Field: EmpSSN

And you have a combo box to pick an employee by name and save the EmpID
in its bound field:

Combo box: cboEmployee
ControlSource: EmpID
RowSource: SELECT EmpID, EmpName, EmpSSN
FROM Employees ORDER BY EmpName;
ColumnCount: 3
BoundColumn: 1
ColumnWidths: 0"; 2"; .5"

Then you could also have text box on the form to show the SSN for the
selected employee:

Text box: txtEmpSSN
ControlSource: =[cboEmployee].[Column](2)

Note that the expression refers to column 2, because in VBA code the
columns of the combo box are numbered starting from 0.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
Thanks for all your help but I was able to figure it out.
I had something wrong in my query that did not allow my
code to work right. It was very minute and it was hard to
pick up. Thank you
 
Back
Top