A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

script control creation



 
 
Thread Tools Display Modes
  #1  
Old August 25th, 2006, 10:44 AM posted to microsoft.public.access.forms
chriske911
external usenet poster
 
Posts: 38
Default script control creation

is there a way to have a bunch of controls created by using code?
I always replace the default record navigation buttons by my own custom
command buttons
this is something I have done thousands of times so far

thnx


  #2  
Old August 25th, 2006, 06:48 PM posted to microsoft.public.access.forms
Access101
external usenet poster
 
Posts: 118
Default script control creation

The HELP file (CreateControl Method) says this and provides this example:

The CreateControl method creates a control on a specified open form. For
example, suppose you are building a custom wizard that allows users to easily
construct a particular form. You can use the CreateControl method in your
wizard to add the appropriate controls to the form.

Example
The following example first creates a new form based on an Orders table. It
then uses the CreateControl method to create a text box control and an
attached label control on the form.

Sub NewControls()
Dim frm As Form
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer

' Create new form with Orders table as its record source.
Set frm = CreateForm
frm.RecordSource = "Orders"
' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
End Sub


"chriske911" wrote:

is there a way to have a bunch of controls created by using code?
I always replace the default record navigation buttons by my own custom
command buttons
this is something I have done thousands of times so far

thnx



  #3  
Old August 28th, 2006, 07:19 AM posted to microsoft.public.access.forms
chriske911
external usenet poster
 
Posts: 38
Default script control creation

Access101 wrote :
The HELP file (CreateControl Method) says this and provides this example:


The CreateControl method creates a control on a specified open form. For
example, suppose you are building a custom wizard that allows users to easily
construct a particular form. You can use the CreateControl method in your
wizard to add the appropriate controls to the form.


Example
The following example first creates a new form based on an Orders table. It
then uses the CreateControl method to create a text box control and an
attached label control on the form.


Sub NewControls()
Dim frm As Form
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer


' Create new form with Orders table as its record source.
Set frm = CreateForm
frm.RecordSource = "Orders"
' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
End Sub


"chriske911" wrote:


is there a way to have a bunch of controls created by using code?
I always replace the default record navigation buttons by my own custom
command buttons
this is something I have done thousands of times so far

thnx


I did see that one but it is not a very dynamic way to create the same
controls over and over again
you could write code that passes the "to be changed form" itself but
still
neither does it allow me to assign events to them within a the affected
form and so on

isn't there anyone else that finds themself creating the same controls
all of the time?
and how does he or she go about it?

thnx


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.