Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Look up based on ONE or MORE

Status
Not open for further replies.

tbonehwd

IS-IT--Management
Joined
Jul 28, 2005
Messages
45
Location
US
I am curious how other people would do the example below. I currently give the user the ability to either leave the Me.cmbADVACCT blank and get all, enter an Account Number "without leading zeros" or enter multiple account numbers "with leading zeros" like '000000777777','000000601248'

Code:
        If IsNull(Me.cmbADVACCT.Value) Then
        strADVITM = " Like '*' "
    Else
        If (Me.chkACCT = True) Then
        strADVACCT = "IN (" & Me.cmbADVACCT.Value & ") "
    Else
        strADVACCT = "='" & Format(Me.cmbADVACCT, "000000000000") & "'"
End If
End If

Would there be a better way to do the above?

Thanks,

Tbonehwd
 
The only thing I'd try is using Is Not Null instead of Like - maybe a little faster if you're crunching loads of data. Have also tweaked your second If statement for immeasurably small speed hike, i.e.
Code:
If IsNull(Me.cmbADVACCT.Value) Then
    strADVITM = " Is Not Null "
Else
    If Me.chkACCT Then
        strADVACCT = "IN (" & Me.cmbADVACCT.Value & ") "
    Else
        strADVACCT = "='" & Format(Me.cmbADVACCT, "000000000000") & "'"
    End If
End If

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top