Bird, Plane, No-Faster than DCount!

Banaticus

Registered User.
Local time
Today, 01:55
Joined
Jan 23, 2006
Messages
153
Faster than DCount with checkbox control

I have a field in a table, value was entered by someone else (not me) as either "pdnnnn" or "nnnn", showing whether a person paid or not.

What's a quick way to parse that field for a check control on a form? For instance, I could use:

If DCount("field", "table", "field alike 'pd%') > 0 Then
Me.Checkthing.Value = True
Else
Me.Checkthing.Value = False
End If

But, it's my understanding that DCounts are rather slow. Is there a better way to do this?
 
Last edited:
Since that'e the only processing going on, in your code, I would think it's the most efficient. What's your other option, open a recordset?(no)

But why DCount, you mean DLookUp?

Watch your wildcard. ADO is '%', but VBA is '*'. Aggregate functions are VBA.

Dim varPaid As Variant

varPaid = DLookUp("pkID", "table", "txtPaid Like 'pd*') 'use Primarykey, will come null, if LookUp field is null, even if there's a record.

If Not IsNull(varPaid) Then
 
if the field is part of the query on which the form is based then there is no need for a lookup.
In the control source of the check box
=IIf(Len([YourField])>4,True,False)

HTH

Peter
 
Thanks, Bat17.
I'm now using:
=IIf(InStr(Text_BeltPrice, "pd"),True,False)
 

Users who are viewing this thread

Back
Top Bottom