Another Easy Access Questions

B

Bob Quintal

Again, I am new to access so thank you all in advance for your
help. Your information and guidance is great.

I have an input form where I have a user input a store#. I then
run a VBA (onUpdate) to validate that the store exists in the
table. I do this by opening a recordset and then do an "if
recordset.eof and recordset.bof then msgbox "does not exist".

Here are my questions:
1. Is there a way to make the user only input numeric values? All
the stores are numeric and the recordset fails if a character is
entered? Or maybe check to see if it is a character and do not
open recordset?

2. Is access quicker (better performance) if I use a dlookup
instead of recordset? If so, how do I then perform a "if else"
depending on whether a record is found. I think I tried this
originally but the dlookup would fail and I could not get passed
it. An example would be great.

Thanks a ton!!!
1: use an input mask, or create an AfterUpdate event for the store
number that sets a flag based on the isnumeric() function to run the
Dlookup or recordset,

2: there's no noticeable difference. I prefer the DLookup() function
as it's less code to be analysed when upgrading an old applicaion.
and is 'self-documenting' that you are looking up some data.


Example Code

if Isnumeric(Me.[Store#]) then
if isnull(Dlookup("[store#]","Stores", _
"[store#] = & me![store#]) then
msgbox "No Store with this Number"
else
....
end if
end if

3: Have you considered changing your store number textbox to a much
more user-friendly combobox that limits the entry to the list of
store numbers?
 
A

AJ

Again, I am new to access so thank you all in advance for your help. Your
information and guidance is great.

I have an input form where I have a user input a store#. I then run a VBA
(onUpdate) to validate that the store exists in the table. I do this by
opening a recordset and then do an "if recordset.eof and recordset.bof then
msgbox "does not exist".

Here are my questions:
1. Is there a way to make the user only input numeric values? All the stores
are numeric and the recordset fails if a character is entered? Or maybe check
to see if it is a character and do not open recordset?

2. Is access quicker (better performance) if I use a dlookup instead of
recordset? If so, how do I then perform a "if else" depending on whether a
record is found. I think I tried this originally but the dlookup would fail
and I could not get passed it. An example would be great.

Thanks a ton!!!
 
J

Jeff Boyce

AJ

There may be an easier way, one that doesn't require users to memorize
store#s, doesn't require a opening a recordset, and doesn't require a
DLookup.

Use a combobox that lists all valid stores (use a query against a "stores"
table). This way, the user simply finds the right store. If this is on an
"input form", you can bind the combobox to the underlying field that will be
holding the storeID.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
A

AJ

Thanks Jeff, but I thought about that and discussed it with the user and
since there are 20,000+ stores we decided that was not a good option. They
will be running this for specific stores and will know them.
 
F

fredg

Thanks Jeff, but I thought about that and discussed it with the user and
since there are 20,000+ stores we decided that was not a good option. They
will be running this for specific stores and will know them.

Jeff's reply is still a better method.
If your user wishes only certain stores to be available for user to
select from, then simply filter the rowsource query to return just
those stores (or create a table with just those store numbers), or if
there are just a very few, set the rowsource type to a Value list, and
simply enter the values directly into the rowsource.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top