Count in combo box

  • Follow


Hi,
I have a form with combo box (combo1)which based on query.
When the form load I would like to count the item in combo1.
If there are no items, the form loading will be canceled and massage "No 
items to choose".

Any ideas,

Thanks,
   T 


0
Reply Tom 5/24/2007 7:46:51 PM

The simplest way would be to use a DCount() function to check before you 
even open the form.

    If DCount("CustID", "Orders", "CustID=123")=0 Then
        MsgBox "No Data available for selected filter."
    Else: DoCmd.OpenForm "myForm"
    End If

-- 
Bill Mosca, MS Access MVP
http://tech.groups.yahoo.com/group/MS_Access_Professionals


"Tom" <partner1973@yahoo.com> wrote in message 
news:uzOPIxjnHHA.3460@TK2MSFTNGP04.phx.gbl...
> Hi,
> I have a form with combo box (combo1)which based on query.
> When the form load I would like to count the item in combo1.
> If there are no items, the form loading will be canceled and massage "No 
> items to choose".
>
> Any ideas,
>
> Thanks,
>   T
> 


0
Reply Bill 5/24/2007 8:20:04 PM


Thanks.
"Bill Mosca, MS Access MVP" <nospam@domain.com> wrote in message 
news:OHDlNEknHHA.1904@TK2MSFTNGP02.phx.gbl...
> The simplest way would be to use a DCount() function to check before you 
> even open the form.
>
>    If DCount("CustID", "Orders", "CustID=123")=0 Then
>        MsgBox "No Data available for selected filter."
>    Else: DoCmd.OpenForm "myForm"
>    End If
>
> -- 
> Bill Mosca, MS Access MVP
> http://tech.groups.yahoo.com/group/MS_Access_Professionals
>
>
> "Tom" <partner1973@yahoo.com> wrote in message 
> news:uzOPIxjnHHA.3460@TK2MSFTNGP04.phx.gbl...
>> Hi,
>> I have a form with combo box (combo1)which based on query.
>> When the form load I would like to count the item in combo1.
>> If there are no items, the form loading will be canceled and massage "No 
>> items to choose".
>>
>> Any ideas,
>>
>> Thanks,
>>   T
>>
>
> 


0
Reply Tom 5/24/2007 9:05:19 PM

2 Replies
455 Views

(page loaded in 0.087 seconds)


Reply: