473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Finding if a value exists in a table

I am trying to write some VBA that can check if a certain value exists in a
field in a table. The field is a text field. The table is not a part of the
query that forms the recordsource of the form on which I am trying to do
this. I wish to act on the presence (or absence) of this value. What I am
doing is trying to have a generic password form such that when you click a
button to open the next form, the code checks if there is a letter for that
form in the PassID field in tblPass. If there is, it opens a password form,
if there is not, it opens the form directly without the need for a password.
The idea is to allow clients to password any form they wish.

For example, the code for opening a form from the current form might be ZZ.
If the value ZZ exists in field PassID in tblPass, the password form will be
opened. If no such value exists, the form is opened directly.

Has anyone any ideas on how I can do this? What I seem to be missing is how
to quiz the table to see if the value exists in that field.

dixie
Nov 13 '05 #1
2 10016
Dookup() should do the job.

See:
Getting a value from a table: DLookup()
at:
http://members.iinet.net.au/~allenbrowne/casu-07.html

Put your code in the form's Open event, and cancel the event if a password
is required and the user cannot give it.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dixie" <di****@dogmail.com> wrote in message
news:vm***************@nnrp1.ozemail.com.au...
I am trying to write some VBA that can check if a certain value exists in a
field in a table. The field is a text field. The table is not a part of
the
query that forms the recordsource of the form on which I am trying to do
this. I wish to act on the presence (or absence) of this value. What I
am
doing is trying to have a generic password form such that when you click a
button to open the next form, the code checks if there is a letter for
that
form in the PassID field in tblPass. If there is, it opens a password
form,
if there is not, it opens the form directly without the need for a
password.
The idea is to allow clients to password any form they wish.

For example, the code for opening a form from the current form might be
ZZ.
If the value ZZ exists in field PassID in tblPass, the password form will
be
opened. If no such value exists, the form is opened directly.

Has anyone any ideas on how I can do this? What I seem to be missing is
how
to quiz the table to see if the value exists in that field.

dixie

Nov 13 '05 #2
I feel so silly. I had already thought of a DLookup, but for some reason
just dismissed it as not being the way to do it. It took me about 2 minutes
to implement this after you confirmed that it WAS the way to do it.

Thankyou.

dixie

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
Dookup() should do the job.

See:
Getting a value from a table: DLookup()
at:
http://members.iinet.net.au/~allenbrowne/casu-07.html

Put your code in the form's Open event, and cancel the event if a password
is required and the user cannot give it.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dixie" <di****@dogmail.com> wrote in message
news:vm***************@nnrp1.ozemail.com.au...
I am trying to write some VBA that can check if a certain value exists in a field in a table. The field is a text field. The table is not a part of
the
query that forms the recordsource of the form on which I am trying to do
this. I wish to act on the presence (or absence) of this value. What I
am
doing is trying to have a generic password form such that when you click a button to open the next form, the code checks if there is a letter for
that
form in the PassID field in tblPass. If there is, it opens a password
form,
if there is not, it opens the form directly without the need for a
password.
The idea is to allow clients to password any form they wish.

For example, the code for opening a form from the current form might be
ZZ.
If the value ZZ exists in field PassID in tblPass, the password form will be
opened. If no such value exists, the form is opened directly.

Has anyone any ideas on how I can do this? What I seem to be missing is
how
to quiz the table to see if the value exists in that field.

dixie


Nov 13 '05 #3

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

Similar topics

4
by: Aaron W. West | last post by:
Timings... sometimes there are almost too many ways to do the same thing. The only significant findings I see from all the below timings is: 1) Integer math is generally fastest, naturally....
3
by: Helgardh | last post by:
I have a linked table (Access 2003) to an Outlook inbox. The body of the e-mail messages are in a memo field. My problem is that I need to "read" the memo and find data on certain lines. The...
7
by: melanieab | last post by:
Hi, I'm trying to use DataView to find the row number in the datatable that contains "Rich" in it so that I can highlight it. It works fine when I enter the entire string (i.e. Richard), but I...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
5
by: Manish | last post by:
This is the print_r() for a variable $categories. $categories :: Array ( =Array ( =Array (
6
by: rshivaraman | last post by:
CREATE TABLE ( (10) NULL ) CREATE TABLE ( (10) NULL )
5
by: maury | last post by:
Hello, I have a DB table with data filled from a weather sensor probe, I have one row every 10 minutes and the data fields is not in DateTime format but in string format: yyyyMMddHHmm So for...
4
by: qwedster | last post by:
Howdy folks! I am using stored procedure to see if a value exists in database table and return 0 if exists or else -1, in the following SQL queries. However how to check if a value (that is...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.