Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Return null values when using wild cards.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 13 Nov 2006 21:27 GMT
I'm using the following code to set up paramenters for a query.  For some
reason, Like '*' isn't returning null values for this field although it is
for other fields.  How can I change this code to read that if Len  = 0 to
return records where Bldg is null as well?  Thanks you much.

'Build Criteria string from Bldg Listbox
For Each VarItem In Me.cmdBldg.ItemsSelected
StrBldg = StrBldg & ",'" & Me.cmdBldg.ItemData(VarItem) & "'"
Next VarItem
If Len(StrBldg) = 0 Then
StrBldg = "Like'*'"
Else
StrBldg = Right(StrBldg, Len(StrBldg) - 1)
StrBldg = "IN(" & StrBldg & ")"
End If
Klatuu - 13 Nov 2006 22:17 GMT
Change:
StrBldg = "Like'*'"
To:
StrBldg = "IS NULL OR Like'*'"

> I'm using the following code to set up paramenters for a query.  For some
> reason, Like '*' isn't returning null values for this field although it is
[quoted text clipped - 11 lines]
> StrBldg = "IN(" & StrBldg & ")"
> End If
John Spencer - 14 Nov 2006 00:01 GMT
Since you want to return all records, why not leave strBldg out of the query's
where clause completely?  IF Len(strBldg) = 0 then ...

> I'm using the following code to set up paramenters for a query.  For some
> reason, Like '*' isn't returning null values for this field although it is
[quoted text clipped - 11 lines]
> StrBldg = "IN(" & StrBldg & ")"
> End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.