Does anyone know what this code is about?

sirantonycartwr

Registered User.
Local time
Yesterday, 16:08
Joined
Dec 10, 2006
Messages
45
This code has been put into my database a few times, i dont know what it is. It never seems to be called, ever. I commented it out and put a messagebox there to tell me when its called. My buttons are always called btnDoThis, etc not command 12. I dont know why its in there but obviously it opens one of my forms for some reason! Does anyone know why its in here? Can i get rid of it?


Code:
Private Sub Command12_Click()
MsgBox "Error in members persons names", , "Unknown Error 6"
'on Error GoTo Err_Command12_Click
'
'    Dim stDocName As String
'    Dim stLinkCriteria As String
'
'    stDocName = "frmStakeholdersMembersSkills"
'
'    stLinkCriteria = "[Person ID]=" & Me![PersonID]
'    DoCmd.OpenForm stDocName, , , stLinkCriteria
'
'Exit_Command12_Click:
'    Exit Sub
'
'Err_Command12_Click:
'    MsgBox Err.Description
'    Resume Exit_Command12_Click

Ant...
 
it opens the form with frmStakeholdersMembersSkills to the appropriate record based on the personID that is located on your active form.

Can you get rid of it? sure if u dont want the form to open to a specific record
 
If you have a button named Command12, that would be it's code. If you renamed the button after putting in the code, then this is roque code and you can delete it if you put the code on the other event for the renamed control.
 
If you have a button named Command12, that would be it's code. If you renamed the button after putting in the code, then this is roque code and you can delete it if you put the code on the other event for the renamed control.

Yeah, thats what i thought too.
I dont have a button for it, and as far as i know i havent had a button for this. Is it deffinately code for a button?

It does say command click which is for a button.

If the button is never clicked because its not there then this method is never going to be called. Is that true?

There is no button for this unless its invisible which i havent done!
 
So this code is for a button called command12 which opens a form with specific data to display?

Ant...
 
More than likely when you added a new button to a form, you used Access's command button wizard, which automatically generates the VBA behind the form.

After the button was created, you more than likely renamed or deleted the button without deleting the code. Unless you create another button and call it Command12 and make sure it has a click event in the properties window, then the code will never be called. It is essentially rogue or spectre code (not roque as previously stated), meaning the code is there, but it isn't ever really seen or executed - it's ghostly.

You should get rid of code that is never executed because it contributes to database bloat, even though it is never used.
 

Users who are viewing this thread

Back
Top Bottom