A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Blank Field in Form



 
 
Thread Tools Display Modes
  #1  
Old December 28th, 2009, 06:47 PM posted to microsoft.public.access.tablesdbdesign
Bvdman32
external usenet poster
 
Posts: 8
Default Blank Field in Form

I have a query that gets some criteria (City and State) from a form.
I have the State field set up as a ComboBox connected to a local table
I created. If a user was to type in a City (i.e. "Springfield") and
then leave the State field empty, then the query would have no
results.

How do I make the query so that if one of the fields on the form is
left empty it will run for all possibilities (i.e. look for all
Springfields in any state)?
  #2  
Old December 28th, 2009, 07:03 PM posted to microsoft.public.access.tablesdbdesign
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Blank Field in Form

Assuming the name of your form is FrmCityState and there are two textboxes
named City and State on the form, put the following expression in the
criteria of the City field in your query:
Forms!FrmCityState!City Or (Forms!FrmCityState!City IsNull)
and put the following expression in the criteria of the State field in your
query
Forms!FrmCityState!State Or (Forms!FrmCityState!State IsNull)

Steve




"Bvdman32" wrote in message
...
I have a query that gets some criteria (City and State) from a form.
I have the State field set up as a ComboBox connected to a local table
I created. If a user was to type in a City (i.e. "Springfield") and
then leave the State field empty, then the query would have no
results.

How do I make the query so that if one of the fields on the form is
left empty it will run for all possibilities (i.e. look for all
Springfields in any state)?



  #3  
Old December 28th, 2009, 08:33 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Blank Field in Form

On Mon, 28 Dec 2009 13:03:31 -0500, "Steve" wrote:

Assuming the name of your form is FrmCityState and there are two textboxes
named City and State on the form, put the following expression in the
criteria of the City field in your query:
Forms!FrmCityState!City Or (Forms!FrmCityState!City IsNull)
and put the following expression in the criteria of the State field in your
query
Forms!FrmCityState!State Or (Forms!FrmCityState!State IsNull)

Steve


I think Steve meant to use

Is Null

rather than

IsNull

since the latter is a VBA function and the former (with the blank) is a valid
SQL criterion.

--

John W. Vinson [MVP]
  #4  
Old December 28th, 2009, 09:03 PM posted to microsoft.public.access.tablesdbdesign
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Blank Field in Form

Thank you for correcting my typo, John!

Steve


"John W. Vinson" wrote in message
...
On Mon, 28 Dec 2009 13:03:31 -0500, "Steve"
wrote:

Assuming the name of your form is FrmCityState and there are two textboxes
named City and State on the form, put the following expression in the
criteria of the City field in your query:
Forms!FrmCityState!City Or (Forms!FrmCityState!City IsNull)
and put the following expression in the criteria of the State field in
your
query
Forms!FrmCityState!State Or (Forms!FrmCityState!State IsNull)

Steve


I think Steve meant to use

Is Null

rather than

IsNull

since the latter is a VBA function and the former (with the blank) is a
valid
SQL criterion.

--

John W. Vinson [MVP]



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.