Re: Is there a better way to code this?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Excellent.

Keep in mind the ELookup(). It is faster and does more than the standard
DLookup().

--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


"bob" wrote:

Steve using a table with the following seems to work fine

If (Not IsNull(DLookup("[DrivingOffenceCodes]", "tblConvictionCodes",
"[ConvictionCode]='" & Me.DrivingOffenceCodes & "'"))) Then
msgbox "YOU MUST REQUEST A COPY"
Cancel = True
End If

I have rename the Combo131 to cboDrivingOffenceCodes as you say it makes it
easier to understand.

Thanks Bob
"Steve Sanford" <limbim53 at yahoo dot com> wrote in message
news:DFA3EDF6-EAA4-4F6C-9F9B-255020E88306@xxxxxxxxxxxxxxxx
I would use a table with a single field (duplicates not allowed).

Then open a recordset Where the [FieldName] = Me.Combo131

(BTW, you should take the time to rename the controls. What is Combo131?
It
is easier to understand if you had renamed it (for example) cboProjCode.

Or you could use DLookUp().
Or, on Allen Browne's site, ELookUp() =>
(http://allenbrowne.com/ser-42.html)

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


"bob" wrote:

Hi is there a better way of doing this I would have to add about 30 more
Me.Combo131 = "" to complete this task? I have tried using the wildcard
Me.Combo131 = "AC(*)" in various ways but none of them work.

If Me.Combo131 = "AC10" Or Me.Combo131 = "AC20" Or Me.Combo131 = "AC30"
Or
Me.Combo131 = "BA10" Or Me.Combo131 = "BA30" Or Me.Combo131 = "CD10" Or
Me.Combo131 = "CD20" Or Me.Combo131 = "CD30" Or Me.Combo131 = "CD40" Or
Me.Combo131 = "CD50" Or Me.Combo131 = "CD60" Or Me.Combo131 = "CD70" Or
Me.Combo131 = "CD71" Or Me.Combo131 = "DD40" Or Me.Combo131 = "DD60" Or
Me.Combo131 = "DD80" Or Me.Combo131 = "DR10" Or Me.Combo131 = "DR20" Or
Me.Combo131 = "DR30" Or Me.Combo131 = "DR40" Or Me.Combo131 = "DR50" Or
Me.Combo131 = "DR60" Or Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or
Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or
Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or
Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or Me.Combo131 = "AC30" Or
Me.Combo131 = "AC30" Then
msgbox "YOU MUST REQUEST A COPY"
End If


Thanks Bob






.



Relevant Pages