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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form not working after upsizing

Status
Not open for further replies.

fludan

Technical User
Feb 1, 2002
41
0
0
US
Hi
I just upsized my database to sql 2000 and it went well, but my form is not working. My VB code is not working.

Private Sub Form_Open(Cancel As Integer)

Dim MySQL As String
Dim Tmp As Variant

MySQL = "SELECT * FROM customer WHERE False"


Me![Look For ferstname] = Null
Me![Look For lastname] = Null
Me![Look For customerID] = Null
Me![Look For city] = Null
Me![Look For address] = Null
Me![Look For phone] = Null


Me![Find Customers Subform].Form.RecordSource = MySQL


Me![Look For customerID].SetFocus

End Sub

Can some one help me
Thank
Frank
 
What do you mean by WHERE False?

SELECT * FROM customer WHERE False

SQL Server requires a column name or something else to compare in a WHERE clause.

What are you testing/looking for?

Are you looking for a string (word) FALSE?
If so, you need single quotes around the string:
'FALSE'

Are you testing for a boolean? If so, you probably need a CASE statement.

Right now your statement, in psuedocode, says:
Show me everything from the customer table where false

It just doesn't make sense.

-SQLBill

 
In VB and Access, a BOOLEAN value is like any other datatype, you can assign it, and True and False are constants. SO "WHERE FALSE" is OK.

In SQLServer, there is no BOOLEAN datatype! (which irks me no end) The result of a comparison like
@var1>@var2
cannot be assigned to a variable. A BIT is logically equivalent but this wont work:
set @bitvar = (@var>@var2)

So where you need a BOOLEAN CONDITION, you cannot simply have a true/false constant (which doesnt exist anyway), or a variable, you MUST have some comparison.

Use something like:
WHERE (0=1)

 
Ok Thanks
What I am trying to do is a search in the table customer, search on the customer name or address or etc.

This code is from an old example from microsoft

Thanks
Frank
 
Hi,
I ran across this thread while looking for a way to set a condition in a query against field with a boolean value. What I ended up deciding on was to check for 1 (if you're looking for a 'TRUE' record) and 0 (when checking for a 'FALSE' record.) This is a work-around for SQL which doesn't allow the user to code "Where booleanfield = True" Instead use: "where booleanfield = 1"
thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top