Q about methods...

shkrebs

Registered User.
Local time
Today, 14:16
Joined
Jun 7, 2002
Messages
60
Hi there.

Maybe this is belonging to the Modules/VBA forum, don't know.

I would like to hear what all you hard-core programmers are doing ;)

In my applications the users shall specify a numbers of criterias (or parametres if you like) and based on those criterias I'm creating reports.

I've done this by using the VBA to "collect" the criterias from the forms and then put them into a query which I'm saving with a CreateQueryDef. BUT to do this I have to delete the same query before I'm running the CreateQueryDef and this is my problem. This method seems to me to be a kind of "pig-programming" :) beside there is also the risk if windows crash the moment between the delete and the create - then I have a problem the next time I run the app.

So this is it. I'll accept all input with a BIG smile :D

Best regards
Søren
 
beside there is also the risk if windows crash the moment between the delete and the create

No problem if you do a quick scan of the .QueryDefs table before you do the delete. Since the name of the query is known, you should be able to find out if that name exists

Dim qdCur as QueryDef
Dim stTarget as String

For Each qdCur in CurrentDB.Querydefs
If qdCur.Name = stTarget Then
{delete that puppy}
Goto Job_done
End If
Next qdCur
Job_done:
{build your new copy of the query}

The above is an example of Murphy's Law, part II.
Part I, everybody knows, is "If it CAN go wrong it WILL go wrong."
Part II, the less remembered half, is "so prevent it from going wrong." Poor Ed Murphy. Everyone knows his somewhat cynical laws. Folks forget that he was a real person with VERY practical ideas in test/experiment engineering.

Anyway, I digress. I don't know about the pig-programming part. The thing is, programming is still personal. You can use the wizards to build some event code, sure! But to put your own mark, your imprimateur on your app - that is something a machine cannot do. And as long as style counts, programming will always be an art, not a science. Therefore, as long as you aren't making a techie mistake, few of us will tell you that you are out-and-out wrong to do X vs Y.

Having said that, I am constrained to point out that if you do this as a multi-user app shared across a network and the database isn't split, you could have the abomination of two users accessing the same form at the same time to do the same thing, and only one query name between them...
 
Hi Doc.

Thanks for your input. And your right about Ed, but then again, a lot of people is remembered for the things they didn't do :D

Have a nice day over there.
Søren
 

Users who are viewing this thread

Back
Top Bottom