making an Access database (2003) that is mainly used by other programmers and tech management as a tool for data validation. I want to put an button on parts of the form that runs code, to show the code that is being run. So the programmers can edit it on the spot. This is for a data validation project with frequent changing of code. Lets assume the code is in a module so the form doesn't need to be saved or in edit mode. Just push the button and up pops the code in code view.
Would it work for you?
Private Sub Command0_Click()
While True
Debug.Print "tt"
If pressed And debugmode Then
Stop
pressed = False
End If
DoEvents
Wend
End Sub
Private Sub Command1_Click()
pressed = True
' You can just put here Stop
End Sub
Edit: I mean use DoEvents and Stop
Hi Avraham,
Viewing the code is not so hard, and really neither is editing it. But I should warn you off a few pitfalls. First, the approach you are discussing amounts to self modifying code which will trip a lot of Antivirus software. Secondly corruption is a constant danger with Access and self modifying code only exacerbates this problem. Any solution you come up with should minimize edits and you should also have a very robust backup and restoration plan. Thirdly self modifying code will prevent you from compiling the database (using mdes) or locking the project. This can lead to some very hard to control and maintain source code.
I would suggest instead that you consider using Pure SQL to do your data modification. You can then store and modify the SQL in a table and then just use CurrentDB.Execute to run it.