Marsh,
I substituted
If DCount("*", "qryGetSubCategory") > 0 Then
It didn't throw an error but it also didn't work as desired. The
cboSelectSubCategory went visible (it shouldn't) but with no records.
The If Not IsNull(DLookup....... one works as desired so I think I'll go
with that for now.
Time spent learning is not wasted time.
Thanks for your help.
Regards,
Mike
"Marshall Barton" <(E-Mail Removed)> wrote in message
news

(E-Mail Removed)...
> Mike Revis wrote:
>>I went back and tried it again and still get "missing operator" etc.
>>
>>Here is what I have that produces the desired result followed by what
>>doesn't. Cut & paste.
>>
>>Private Sub cboSelectCategory_AfterUpdate()
>>
>>If DLookup("[subcategory]", "qryGetSubCategory") > 0 Then
>>Me.cboSelectSubCategory.Visible = True
>>Me.cboSelectSubCategory.RowSourceType = "table/query"
>>Me.cboSelectSubCategory.RowSource = "qrygetsubcategory"
>>
>>Else
>>
>>Me.cboSelectPart.Visible = True
>>Forms!frmmainmenu!cboSelectPart.RowSourceType = "Table/Query"
>>Forms!frmmainmenu!cboSelectPart.RowSource = "qryGetPartWithoutSubCategory"
>>
>>End If
>>
>>End Sub
>>
>>
>>++This gets the error.
>>
>>Private Sub cboSelectCategory_AfterUpdate()
>>
>>If DLookup("*", "qryGetSubCategory") > 0 Then
>>Me.cboSelectSubCategory.Visible = True
>>Me.cboSelectSubCategory.RowSourceType = "table/query"
>>Me.cboSelectSubCategory.RowSource = "qrygetsubcategory"
>>
>>Else
>>
>>Me.cboSelectPart.Visible = True
>>Forms!frmmainmenu!cboSelectPart.RowSourceType = "Table/Query"
>>Forms!frmmainmenu!cboSelectPart.RowSource = "qryGetPartWithoutSubCategory"
>>
>>End If
>>
>>End Sub
>
>
> You did nothing wrong beyond taking my word for what the
> code should be. I was really thinking DCount, but my idiot
> fingers typed DLookup and my eyes read DCount. I can't
> believe I did that. I even proof read it twice. What kind
> of brain fault am I suffering from? (Note to self: Run the
> brain path diagnostics - again)
>
> Let me try one more time:
>
> If DCount("*", "qryGetSubCategory") > 0 Then
>
> Actually, you did well to make the DLookup work. The reason
> it worked for you is that DLookup returns Null if it doesn't
> find anything. And comparing Null to zero is also Null (not
> True or False) so the If fails. That's an obscure way to do
> it and if you prefer using DLookup for this, it should be
> written:
>
> If Not IsNull(DLookup("subcategory", "qryGetSubCategory"))
> Then
>
> Sorry for all the time you wasted on this.
>
> --
> Marsh
> MVP [MS Access]