Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Time Error 7874 Question

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
New to VB applications....

Can anybody find anything wrong with this snippet of code?
I attached it (as "=ClearForm()" ) to a button I put on a Form to activated with a 2ble click. The message returned is a run-time 7874 error with words to the effect that the system cannot find the object named in the first Docmd. My guess would be that there's a problem with the naming convention, but what?

Option Explicit

Function ClearForm()

DoCmd.OpenQuery "[Normalizing Target Lesions Data]", acViewNormal, acReadOnly
DoCmd.Close acQuery, "[Normalizing Target Lesions Data]", acSavePrompt

DoCmd.OpenQuery "[Convert Union Query Result into Table]", acViewNormal, acReadOnly
DoCmd.Close acQuery, "[Convert Union Query Result into Table]", acSavePrompt

DoCmd.OpenQuery "[Sum of Target Lesions Query]", acViewNormal, acReadOnly
DoCmd.Close acQuery, "[Sum of Target Lesions Query]", acSavePrompt

DoCmd.OpenQuery "[Make Table w/ Visit Sums]", acViewNormal, acReadOnly
DoCmd.Close acQuery, "[Make Table w/ Visit Sums]", acSavePrompt

End Function

 
Assuming you have a query named "Normalizing Target Lesions Data" exactly, you're good. If you're off by a letter (either in the query name or in the code) it will fail, like you described above. It looks like the spelling is correct in your code above, so check your query name.



At any rate, spaces in table/query/form names make me nervous. It's all much simpler when you use totally unintellible query names like "qryrptNormTtLs" and "alf".

Whatever makes you happy.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
????

Well, I re-re-read through the typing and could discern no visible typos. What I did was to copy the various queries out as "A", "B", "C" and "D" to test whether the code had integrity and that seemed to work, so go figure.

But, now the Russian Doll opens to reveal a clone of itself....and

I find the sub-form that should reflect the updated values of the assorted interdigitations does not, although the source of the sub-form does!

 
The way you can guarantee your query names are the same is to click (ONCE) on the query, press F2. This will highlight EVERYTHING in the name. Press CTRL-C, and you've got the query name in the Clipboard.


Moving on.


Do a "Forms![subFormNameHere].Requery" after running all the queries, and it should be good. No, I don't know why it didn't update automatically.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
My reaction to your (thoughtful) reply would be as under:

Regarding this part --

The way you can guarantee your query names are the same is to click (ONCE) on the query, press F2. This will highlight EVERYTHING in the name. Press CTRL-C, and you've got the query name in the Clipboard.


Could you flesh that out a bit? Were you talking about highlighting the query name in the VBA code I submitted as part of my posting to this technical discussion group?

Now the third and final half:

Do a "Forms![subFormNameHere].Requery" after running all the queries, and it should be good. No, I don't know why it didn't update automatically

Were you talking about using the command in your sentence above literally in a VBA function?


 
1/2: I'm just talking about a general technique to harvest filenames/query names/etc. In the database view (this has nothing to do with VBA) click on the query in question. Then copy the contents to the clipboard, and directly paste them into VBA.

You see what I'm saying.



2/2: Literally add the line "Forms![subFormNameHere].Requery" -- of course replacing "subFormNameHere" with your subform's name.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top