View Full Version : Help/Advice needed for Exceptions


evermore
02-18-2009, 03:14 PM
Hi everyone

At the moment i have a form(FORM A) which contains a button(BUTTON A). When i press BUTTON A, it opens a query (QUERY A) which prompts the user to enter an input criteria to search TABLE A.

QUERY A is a Make Table Query, so basically my search/find results are being saved into a table (TABLE B).

I export TABLE B further on to .csv

Ok, so for instance, if i press BUTTON A and type in a search and press OK, everything works fine.
The second time around, im asked if i want to replace the existing TABLE B.( i have turned off the 3 prompt options in edit/find, but this still appears, although im not that worried).
I press Yes, and the prompt appears again, although this time i press cancel.

Now when i go to export to .csv, there is no TABLE B to export and an error occurs.

My question is, should i be adding exception handling to the csv export function or is there something i can do earlier on in the piece (BUTTON A function) that will be easier?

Thankyou so much.

EDIT: I decided to accompany BUTTON A with a txtbox, now the prompt does not occur and the table is always created, even if the txtbox is empty.

Thanks for those who looked at the thread.

DCrake
02-19-2009, 12:40 AM
What you need to do is use an append query instead of an make table query.

First create Table B in its expected format, then when you press your button you first delete all the existing records in Table B and then append the results from the query into table B.

However why not simply export the query directly without making or updating a table.

David

evermore
02-19-2009, 01:04 PM
Thats what i tried to do initially, but this program is existing and i dont want to change the function that exports to .csv (without notifying the original author who is away at the moment)

it brings up an argument complaint when i try to export the query directly, although if i create a table from the query and export that, no problems.

I was wondering if i could get a bit of help on another problem.

Im trying to make the criteria in my query sensitive to partial matches, but i dont want substrings within strings to be found.

for example

the id 'QERTY765' would show up positive from the criteria E or ERT or anything within that.

At the moment i am using Like "*"&[...]&"*".
is there anyway i can include some sort of function after the first asterisk to look for the start of the id.

so that if i enter QERT it will find that specific id, but if i enter ERT or T, it wont.

P.S all the id's start with a Q, but i dont think this helps, as the user will enter the q in there search.

Thank you very much.

jal
02-19-2009, 04:13 PM
I don't understand. If you want to insure that the user's criteria captures the beginning of the word, then remove the first asterisk. Change this:

SELECT * FROM Customers WHERE ID LIKE *Criteria*

to this:

SELECT * FROM Customers WHERE ID LIKE Criteria*

Thus if the the ID is QERT, a search for "ERT" will fail. The following will succeed:
Q
QE
QER
QERT

I suppose I'm probably misunderstanding you.

evermore
02-19-2009, 06:38 PM
You are right, thanks for your help.