473,473 Members | 4,189 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB - Question for OpenForm Criteria

In " vb help" the example for OpenForm Method works fine...

DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

However if I try to apply the example to my field which is a "yes or
no" it does not.

Is there some way to do it?

DoCmd.OpenForm "Employees", , ,"answer = 'yes'"

or

DoCmd.OpenForm "Employees", , ,"answer = '-1'"

Does not produce the desired results...
Nov 12 '05 #1
2 2153
Nairb wrote:
In " vb help" the example for OpenForm Method works fine...

DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

However if I try to apply the example to my field which is a "yes or
no" it does not.

Is there some way to do it?

DoCmd.OpenForm "Employees", , ,"answer = 'yes'"

or

DoCmd.OpenForm "Employees", , ,"answer = '-1'"

Does not produce the desired results...

You are attempting to write the Where clause using an expression that is
for a string.
However a Yes/No field is a Boolean field
(a Number, -1 for Yes, 0 for No)
So, for Yes:
"[Answer] = -1"
Or for No:
"[Answer] = 0"
No quotes around the number.

See Access Help files regarding:
Where clause + Restrict data to a subset of records
--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
Nov 12 '05 #2
bg***@yahoo.com (Nairb) wrote in message news:<33**************************@posting.google. com>...

DoCmd.OpenForm "Employees", , ,"answer = 'yes'"

or

DoCmd.OpenForm "Employees", , ,"answer = '-1'"

Does not produce the desired results...

Just a guess, but try this:

DoCmd.OpenForm "Employees", , ,"answer = True"

Since Booleans ("yes or no" fields) aren't strings, you don't have to
put them in quotes. They're either True or False.

When you put quotes around 'yes' it becomes the word yes, not a True
value. So when you compare the Boolean value in the answer field to a
String, you're comparing different data types and that's going to give
you an error.

Hope this makes sense,
Bill
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kurt Blom | last post by:
Hi all, In my current project, I open other forms from within my 'Parentform'. In this parentform, dates of the selected forms are queried. Each time, the parentform (frmParentForm) is minimized...
3
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such...
8
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but...
4
by: Beejer | last post by:
Greeting, I'm trying to launch an OpenForm function with a double criteria. I can't seem to make them work together, the two criteria work seperatly so I assume my code to synchronise both...
3
by: griffiji | last post by:
Ok, I have read this group until I think my eyes are ready to bleed, so I would be most appreciative of some help. I have a form, on it are 3 combo boxes, and 3 text boxes I have 1 table, with...
6
by: keri | last post by:
I am trying to; Click on a textbox in a form called frmcalendar to open another form petalplanning (I can do that bit). However I want the form to open at a certain record depending on the date...
1
by: mchlle | last post by:
I need for a form to display certain records based on the user. If current user = user1 or user2 then open frmNotesAll If current user = user 3 then open frmNotes where counselor id = 2 or 6 or...
2
by: mark mestrom | last post by:
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code: Private Sub Knop22_Click() On Error GoTo Err_Knop22_Click Dim stDocName As String Dim...
3
by: ladybug76 | last post by:
Hello Again. I'm so close I can TASTE IT! I'm working in Access 2003. I've read a bunch of posts, but still can't get to the bottom of this. I have a "Selection Criteria" form (with Two...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.