Automation Questions

George Too

Registered User.
Local time
Today, 05:15
Joined
Aug 12, 2002
Messages
198
Hello All,
I have some questions regarding automation with Access 97. First of all, thanks to http://www.candace.tripp.net/ I have a sample database which automatically creates tables and forms. Now, my question is about code. Is it possible to add code to an already existing form automatically.
Basically, what I want to do is to create a form based on user-entered info and add a couple of lines of code to the calling form. Doable?

Thanks,
George
 
WayneRyan, can you please repost that link. There seems to be something wrong with it.

Thanks,
George
 
Not sure if this is the post Wayne was trying to direct you to.

The code there alters lines of code in modules although you can modify it to achieve what you wish.

Link
 
I've tried and tried but have no idea how to proceed. I have a form with 255 textboxes (txtChar1, .., txtChar255). I need to add code to the double-click code.
Code:
txtNum = 1
PreviewChar (txtNum)
How can I do this quickly? Incidentally, I don't need ALL of the to have

txtNum = 1

txtNum should acually be the number after txtChar in the control name.

I can do this manually :eek: but would like to know if I can automate this kinda thing.
 
OK, I've got this far.. need some help
Code:
Dim myFrm As Form
Set myFrm = Forms![frmFont]

Dim ctrlCode As Module
Set ctrlCode = myFrm.Module

For i = 1 To 255
        
   lngReturn = ctrlCode.CreateEventProc("DblClick", "txtChar" & i)
      With ctrlCode
         .InsertLines lngReturn + 1, "txtNum = Right(Me.ActiveControl.Name,
         Len(Me.ActiveControl.Name) - 7)"
         .InsertLines lngReturn + 2, "PreviewChar (txtNum)"
      End With
Next i
The code is inserted OK, and looking in the VBA window, the code is there. BUT, the code won't run. I have to go the the textbox's propertiy box, and the Event Tab use the combobox for the textbox and choose [Event Procedure].
:confused:
 
Last edited:
Added this at the end and it now works;
Code:
For j = 1 To 255
    myFrm.Controls("txtChar" & i).DblClick = "[b][Event Procedure][/b]"
Next j
BUT, only if the form I am trying to add code to is open in Design view. If not, then the code is added but then I have the problem as I had before.

BTW, I am calling this function from a different form than the one I am adding code to, in case that makes any difference.
 

Users who are viewing this thread

Back
Top Bottom