Assign the IS NOT NULL to a variable (1 Viewer)

miguel vasquez

Registered User.
Local time
Today, 14:27
Joined
Nov 11, 2002
Messages
36
Anyone knows how to assign the a IS NOT NULL to a variable

strDept = "'is not null'" ******** THIS DOESN'T WORK **********
 

KenHigg

Registered User
Local time
Today, 09:27
Joined
Jun 9, 2004
Messages
13,327
So you have a string variable and you want to set it to anything but null???
 

RuralGuy

AWF VIP
Local time
Today, 07:27
Joined
Jul 2, 2005
Messages
13,825
But this will! - strDept = "is not null"
How about explaining what you are trying to accomplish.
 

miguel vasquez

Registered User.
Local time
Today, 14:27
Joined
Nov 11, 2002
Messages
36
I have a drop down in my form, so when I select All in my department Name, I want to assign is not null to a variable, because I have a SQL statement based on my variables, see below...Thanks in advance


If Me.DeptName <> "All" Then
strDept = "'" & Me.DeptName & "'"

ElseIf Me.DeptName = "All" Then
strDept = "'is not null'"

End If

strSQL = "Select * into ReportTable from MainTable Where (type =" & strRPT & " or type =" & strRPT1 & ") and (DepartmentName =" & strDept & ")"
DoCmd.RunSQL strSQL
DoCmd.OpenTable "ReportTable", acNormal, acEdit
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 14:27
Joined
Sep 12, 2006
Messages
15,743
try setting strdept = "*", to see if that returns everything in your query?
 

miguel vasquez

Registered User.
Local time
Today, 14:27
Joined
Nov 11, 2002
Messages
36
I know that I need to assign a specific value to a variable. My question is can assign is not null to a variable. I am passing the value to a SQL statement.

I need help on this issue!!!!
 

jeremypaule

Registered User.
Local time
Today, 09:27
Joined
Aug 21, 2006
Messages
135
make an IF statement before the SQL?

IF not null then
 

RuralGuy

AWF VIP
Local time
Today, 07:27
Joined
Jul 2, 2005
Messages
13,825
There are other issues with your current structure. Why not just create different strSQL depending on the value of Me.DeptName?
 

Users who are viewing this thread

Top Bottom