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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic form creates visible module 1

Status
Not open for further replies.

chirpyform

Programmer
Joined
Jun 20, 2003
Messages
202
Location
FR
I create a form dynamically and then insert some objects (Labels) into the form. I create some event code for the objects using CreateEventProc and inserting lines of code.
However in doing so the user sees the module Form_DynamicallyCreatedForm (the module with the event code) and I don't want this (it should seem like the form already existed).
Is there an option for hiding the module, I can't close it because you can't add code to a closed module. I tried doing DoCmd.SelectObject acModule, module.Name
DoCmd.Minimise but that didn't work (It told me that the form wasn't open, I presume that was because I was in mode creation).

Any suggestions very welcome
Chirpy

P.S. If the question has already been posed appologies but
I tried doing a search in tek tips but I got no response to my search criteria (no matter what i put in the search)
 
You could try turning off the screen echo when doing
the module creation like so:

Code:
Application.Echo False
DoCmd.Hourglass True
'
'Do module creation here
'
Application.Echo True
DoCmd.Hourglass False

Regards...
 
Perfect 1 star thanks
Chirpy
 
chirpyform,

I am looking for a way to dynamically create (or re-create) a form when a user requires an extra field on the form. Seems like you create forms dynamically. Could you point me to the solution please?

Thanks
 
There are a maximum number of objects that can be put in a form. I'll give you several lines of code that could help :

Create a form that has the right size with some attributes that you want (called BaseForm) then

dim frm as Form
Set frm = CreateForm(currentdb.Name, "BaseForm")
frm.Caption = "Title : "

To create lines of code attached to the form :
dim mdl as module
Set mdl = frm.module
Dim lngreturn As Long
dim ctlBox as Control
lngreturn = mdl.CreateEventProc("MouseUp", ctlBox.Name)
mdl.InsertLines lngreturn + 1, vbTab & "If Button = 2 Then _"

To create a control on the form :
Dim ctl As control
Set ctl = CreateControl(frm.Name, acRectangle, , , , 0, 0, 8990, 14000)
ctl.BackColor = RGB(240, 240, 240)
ctl.BackStyle = 1

Hope this helps


Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top