By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,461 Members | 2,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,461 IT Pros & Developers. It's quick & easy.

Finding if a value exists in a table

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.