Yes/No to boolean

xMax

Registered User.
Local time
Today, 16:16
Joined
Aug 7, 2006
Messages
35
I need to know how I can get code in Visual Basic to understand a Yes/No field in a table? I would prefer using booleans, but anything is fine.
 
VB is flexible. You can say True:False or -1:0 or even Yes:No.

True/False is more efficient, though.
 
ok I am putting a field, enablethis = DLookUp ("candothis", "tbltable", tblname = " & cmbtblname)

enablethis is a boolean

candothis is a yes or no field
tbltable is a table
tblname is a text field in a table
cmbtblname is a text field on the form

I'm getting an error message that says "You canceled the previous operation" whenever I try to run the program. What do I do?
 
I think the syntax is incorrect. Search forums to get right syntax.
 
enablethis = DLookup ("candothis", "tbltable", "tblname = " & cmbtblname)

This is what it looks like. Syntax is correct (I use other DLookup commands and they work).
 
Try

enablethis = DLookup ("candothis", "tbltable", "tblname = '" & cmbtblname & "'")

since cmbtblname is a string
 
doesn't work. I think the problem deals with the boolean statement.
 
I get that error if I don't use the ' or if I have the field names etc wrong.
 
Last edited:
Now that makes sense-

If you use a string, you cannot get a null, only a zero length string, and that's not really evaluable.

If you want to keep the string, you need do something like this:

Code:
TestCriteria= Dlookup()
If Len(TestCriteria) Then EnableThis
 

Users who are viewing this thread

Back
Top Bottom