473,382 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

inserting dynamic controls in a form , one overlapping the other

26
I have code to create an access form , and the controls will be added dynamically , taking information about type of form control, answers , questions, answer type control , number of answer type control.

How to put the Question label ,Answer values and answer controls in the form by calculating the x-axis and y-axis values ?

I am adding certain number for every loop counter , to increment teh x- axis and y-axis variable value for inserting teh control but they seem to overlap each other ?

How do i calculate?Is there an easier way to doing this ?
Apr 11 '11 #1
1 1888
ADezii
8,834 Expert 8TB
The following Code should help you. It will create 10 Text Boxes, along with their associated Labels, and align them Vertically with space in between:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCreateControls", acDesign, , , , acWindowNormal
  2.  
  3. Dim ctlText As Control
  4. Dim ctlLabel As Control
  5. Dim intDataX As Integer
  6. Dim intDataY As Integer
  7. Dim intLabelX As Integer
  8. Dim intLabelY As Integer
  9. Dim intCtlCtr As Integer
  10. Dim intHeight As Integer
  11. Dim intWidth As Integer
  12.  
  13. intLabelX = 1000
  14. intLabelY = 300
  15. intDataX = 3000
  16. intDataY = 300
  17. intHeight = 400
  18. intWidth = 1900
  19.  
  20. For intCtlCtr = 1 To 10
  21.   'Create unbound default-size text box in detail section.
  22.   Set ctlText = CreateControl("frmCreateControls", acTextBox, , "", "", _
  23.                                intDataX, (intDataY * intCtlCtr) + (intCtlCtr * intHeight), , intHeight)
  24.  
  25.   'Create child label control for text box.
  26.   Set ctlLabel = CreateControl("frmCreateControls", acLabel, , ctlText.Name, "", _
  27.                                 intLabelX, (intLabelY * intCtlCtr) + (intCtlCtr * intHeight), intWidth, intHeight)
  28.       ctlLabel.BorderStyle = 1      'Solid
  29. Next
  30.  
  31. DoCmd.Close acForm, "frmCreateControls", acSaveYes
Apr 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
3
by: Tyler Carver | last post by:
I am trying to use some dynamic controls that are built and then added to tables. The problem that I am having is the timing of when I can populate the controls and have the state remain after a...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
4
by: Paul W | last post by:
i have some dynamic controls that i add to a webform (actually, i dynamiclly build a table and add the controls to cells). some of these controls are HtmlSelect controls with the multiple property...
3
by: WebBuilder451 | last post by:
I have a series of dynamic link buttons created based upon a datareader. I've added a click event and it calls the sub ok: example: "while loop through the reader" Dim ltrCtrl As New...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
3
by: Andreas Wöckl | last post by:
Hi Group! I have a web form that is created dynamically - so I create Textboxes, RadioButtonLists, CheckBoxLists and so on - I have found some articles that there may be some problems with...
0
by: Scott Roberts | last post by:
I always thought that the viewstate "keys" included the control ID. As long as the control IDs were unique, there shouldn't be any conflicts. Well, it appears that that may not be the case with...
13
by: tommymo | last post by:
Hi everyone I'm new to this site and the world of ASP.Net C# programming. I have been learning controls and integrating them with a SQL database. So far I have been able to move along and understand...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.