Combo is null

  • Thread starter Thread starter Walter
  • Start date Start date
W

Walter

I have 3 unbound combos on a form. Combo2's rowsource uses combo1's value as
criteria. Combo1's AfterUpdate Event requeries combo2. Upon making a
selection in combo1, there are no choices in combo2. Also after update of
combo1, if Combo1 = "this value" then do this. In testing with a code break
there, combo1 is null even though "this value" is selected.
Combo1 Rowsource:
SELECT DISTINCT MyTable.Field1
FROM MyTable
WHERE (((MyTable.Field3)=False));

Combo2 Rowsource:
SELECT DISTINCT MyTable.Field2 FROM MyTable WHERE
(((MyTable.Field1)=[me].[MyCombo1]) AND ((MyTable.Field3)=False));

Column count:1
Bound Column:1
RowSource Type:table/query
LimitToList:Yes
ColumnWidth:1"
 
Walter

Is that SQL statement "in" your form, or is it the query's SQL?

By the way, what data type is MyTable.Field1? Based on your second SQL, it
would have to be a number data type, since you didn't use any delimiters
around the [me].[MyCombo1] ...

I probably would have used Forms!MyForm!MyCombo1 to specify the value in
MyCombo1 ...

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
The sql is copied from the combo's property sheet. The data type is text. I
suspected this was the issue however I've been unable to get the delimiters
right. What is the benefit to using the forms!MyForm!MyCombo! ?
--
Thanks for your help!
Walter


Jeff Boyce said:
Walter

Is that SQL statement "in" your form, or is it the query's SQL?

By the way, what data type is MyTable.Field1? Based on your second SQL, it
would have to be a number data type, since you didn't use any delimiters
around the [me].[MyCombo1] ...

I probably would have used Forms!MyForm!MyCombo1 to specify the value in
MyCombo1 ...

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Walter said:
I have 3 unbound combos on a form. Combo2's rowsource uses combo1's value
as
criteria. Combo1's AfterUpdate Event requeries combo2. Upon making a
selection in combo1, there are no choices in combo2. Also after update of
combo1, if Combo1 = "this value" then do this. In testing with a code
break
there, combo1 is null even though "this value" is selected.
Combo1 Rowsource:
SELECT DISTINCT MyTable.Field1
FROM MyTable
WHERE (((MyTable.Field3)=False));

Combo2 Rowsource:
SELECT DISTINCT MyTable.Field2 FROM MyTable WHERE
(((MyTable.Field1)=[me].[MyCombo1]) AND ((MyTable.Field3)=False));

Column count:1
Bound Column:1
RowSource Type:table/query
LimitToList:Yes
ColumnWidth:1"
 
The Forms!MyForm!MyCombo reference corrected the situation without any
delimiters.
--
Thanks for your help!
Walter


Jeff Boyce said:
Walter

Is that SQL statement "in" your form, or is it the query's SQL?

By the way, what data type is MyTable.Field1? Based on your second SQL, it
would have to be a number data type, since you didn't use any delimiters
around the [me].[MyCombo1] ...

I probably would have used Forms!MyForm!MyCombo1 to specify the value in
MyCombo1 ...

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Walter said:
I have 3 unbound combos on a form. Combo2's rowsource uses combo1's value
as
criteria. Combo1's AfterUpdate Event requeries combo2. Upon making a
selection in combo1, there are no choices in combo2. Also after update of
combo1, if Combo1 = "this value" then do this. In testing with a code
break
there, combo1 is null even though "this value" is selected.
Combo1 Rowsource:
SELECT DISTINCT MyTable.Field1
FROM MyTable
WHERE (((MyTable.Field3)=False));

Combo2 Rowsource:
SELECT DISTINCT MyTable.Field2 FROM MyTable WHERE
(((MyTable.Field1)=[me].[MyCombo1]) AND ((MyTable.Field3)=False));

Column count:1
Bound Column:1
RowSource Type:table/query
LimitToList:Yes
ColumnWidth:1"
 
Text is delimited with quotes.

"Me." refers to the active form (or report).

"Forms!MyForm!MyCombo" explicitly points at a specific control on a form.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Walter said:
The sql is copied from the combo's property sheet. The data type is text.
I
suspected this was the issue however I've been unable to get the
delimiters
right. What is the benefit to using the forms!MyForm!MyCombo! ?
--
Thanks for your help!
Walter


Jeff Boyce said:
Walter

Is that SQL statement "in" your form, or is it the query's SQL?

By the way, what data type is MyTable.Field1? Based on your second SQL,
it
would have to be a number data type, since you didn't use any delimiters
around the [me].[MyCombo1] ...

I probably would have used Forms!MyForm!MyCombo1 to specify the value in
MyCombo1 ...

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Walter said:
I have 3 unbound combos on a form. Combo2's rowsource uses combo1's
value
as
criteria. Combo1's AfterUpdate Event requeries combo2. Upon making a
selection in combo1, there are no choices in combo2. Also after update
of
combo1, if Combo1 = "this value" then do this. In testing with a code
break
there, combo1 is null even though "this value" is selected.
Combo1 Rowsource:
SELECT DISTINCT MyTable.Field1
FROM MyTable
WHERE (((MyTable.Field3)=False));

Combo2 Rowsource:
SELECT DISTINCT MyTable.Field2 FROM MyTable WHERE
(((MyTable.Field1)=[me].[MyCombo1]) AND ((MyTable.Field3)=False));

Column count:1
Bound Column:1
RowSource Type:table/query
LimitToList:Yes
ColumnWidth:1"
 
Back
Top