473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Labels in a new form

markryan57
21 New Member
Greetings,
I searched for this, but cannot find exaclty what I am looking for. I am trying to dynamically create labels on a form just before it opens. I am reading from a database, building the labels then opening the form.

Currently I have put the labels (in a control array) on the form I want to receive the variables. Then I create a loop to read in the db and build the labels, then open the form.

I have like 300 control arrays to build, and would love to dynamically create everything.

the code I have thus far is:
Expand|Select|Wrap|Line Numbers
  1. While Not rs.EOF
  2.     If IsNull(rs("Eclient")) = False Then
  3.         frmClientStatus.lblClient(i).Caption = rs("Eclient")
  4.     End If
  5. Load frmClientStatus
  6. With frmClientStatus
  7.     .lblTestClient (i)
  8.     .Left = "500"
  9.     .Top = "500"
  10.     .Caption = "test"
  11.     .Visible = True
  12. End With
  13.     If IsNull(rs("InforceDate")) = False Then
  14.         frmClientStatus.InforceDate(i).Caption = rs("InforceDate")
  15.     End If
  16.  
there are more if statements below, but I cut them out for brevity.

love to hear any ideas - thanks a mil.

Mark
Feb 21 '07 #1
8 2518
willakawill
1,646 Top Contributor
Hi. You have omitted the end of the while loop which is important in this context. Can you say what it is you are trying to achieve without talking about it in terms of a solution?
Feb 21 '07 #2
markryan57
21 New Member
Thanks for the prompt response, yes I let off several steps below just for brevity sake. What I am trying to do is place labels on a form, poplate their caption with a database recordset, then open the form to display the status results.

Sorry - looking at it, I did not make that terribly clear eh?

thanks

Mark
Feb 21 '07 #3
willakawill
1,646 Top Contributor
We are still without the remainder of the loop. I know that you have said you left out parts that don't matter for brevity. You have also left out parts that do matter.
Are you planning to be displaying a different number of labels each time? Will this number of labels be unlimited?
Feb 21 '07 #4
markryan57
21 New Member
Sorry I was trying to not clog up the screen with the code, here it is the entire routine. Yes the number of labels will or could change each time based on how many cllients are put in by each analyst.

The method below is where I actually went into the status form and created labels (in a control array) for each one (a pain). The parts that are commented out are the new method of dynamically creating the labels.

sorry for the confusion.

and thanks for the help
mark


Expand|Select|Wrap|Line Numbers
  1. Begin Sub
  2. Dim conn1 As ADODB.Connection
  3. Set conn1 = New ADODB.Connection
  4. Dim constr As String
  5. Dim rs As ADODB.Recordset
  6. Dim i As Integer
  7. Dim lblClient() As Label
  8. Dim lblCleanup() As Label
  9. Dim lblAccess() As Label
  10. Dim lblExcel() As Label
  11. Dim lblSeriatim() As Label
  12. Dim lblInforceDate() As Label
  13. Dim Import() As Label
  14. Dim lblResearch() As Label
  15. Dim lblMaster() As Label
  16. Dim lblCopyToClient() As Label
  17. Dim lblRetrieveResearch() As Label
  18. Dim lblDone() As Label
  19. Dim lblTestClient() As Label
  20.  
  21. i = 0
  22. constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=L:\vbfolder\????.mdb"
  23. conn1.Open constr
  24. Set rs = conn1.Execute("Select * from InforceLog WHERE AnalystName = '" & cboSelectName.Text & "'")
  25.  
  26.  
  27. While Not rs.EOF
  28.     If IsNull(rs("Eclient")) = False Then
  29.         frmClientStatus.lblClient(i).Caption = rs("Eclient")
  30.     End If
  31. 'Load frmClientStatus
  32. 'With frmClientStatus
  33. '    .lblTestClient (i)
  34. '    .Left = "500"
  35. '    .Top = "500"
  36. '    .Caption = "test"
  37. '    .Visible = True
  38. 'End With
  39.     If IsNull(rs("InforceDate")) = False Then
  40.         frmClientStatus.InforceDate(i).Caption = rs("InforceDate")
  41.     End If
  42.     If IsNull(rs("Cleanup")) = False Then
  43.         frmClientStatus.lblCleanup(i).Caption = rs("Cleanup")
  44.     End If
  45.     If IsNull(rs("Accessdb")) = False Then
  46.         frmClientStatus.lblAccess(i).Caption = rs("Accessdb")
  47.     End If
  48.     If IsNull(rs("Excel")) = False Then
  49.         frmClientStatus.lblExcel(i).Caption = rs("Excel")
  50.     End If
  51.     If IsNull(rs("seriatim")) = False Then
  52.         frmClientStatus.lblSeriatim(i).Caption = rs("Seriatim")
  53.     End If
  54.     If IsNull(rs("ImportSeriatim")) = False Then
  55.         frmClientStatus.Import(i).Caption = rs("ImportSeriatim")
  56.     End If
  57.     If IsNull(rs("Research")) = False Then
  58.         frmClientStatus.lblResearch(i).Caption = rs("Research")
  59.     End If
  60.     If IsNull(rs("RetrieveResearch")) = False Then
  61.         frmClientStatus.lblRetrieveResearch(i).Caption = rs("RetrieveResearch")
  62.     End If
  63.     If IsNull(rs("UploadToMaster")) = False Then
  64.         frmClientStatus.lblMaster(i).Caption = rs("UploadToMaster")
  65.     End If
  66.     If IsNull(rs("Eclientcopy")) = False Then
  67.         frmClientStatus.lblCopyToClient(i).Caption = rs("EclientCopy")
  68.     End If
  69.  
  70.     If IsNull(rs("Eclient")) = False And IsNull(rs("InforceDate")) = False And IsNull(rs("Accessdb")) = False And IsNull(rs("Excel")) = False And IsNull(rs("Seriatim")) = False And IsNull(rs("ImportSeriatim")) = False And IsNull(rs("UploadToMaster")) = False And IsNull(rs("EclientCopy")) = False Then
  71.         frmClientStatus.lblDone(i).Caption = "*"
  72.     End If
  73.  
  74.     i = i + 1
  75. rs.MoveNext
  76. Wend
  77.     If cboSelectName.Text = "" Then
  78.         MsgBox "Please select name before continuing", vbOKOnly + vbInformation
  79.         Exit Sub
  80.     End If
  81.  
  82.   frmClientStatus.Show
  83.   Set conn1 = Nothing
  84.   Set rs = Nothing
  85.  
  86.     frmClientStatus.Show
  87.  
  88. end sub
  89.  
Feb 21 '07 #5
willakawill
1,646 Top Contributor
And the second part of this question:
Are you planning to be displaying a different number of labels each time? Will this number of labels be unlimited?
Feb 21 '07 #6
markryan57
21 New Member
The labels for each run are laid out in a grid format

Client Date Step1 Step2 Step3 Step4 .......

XXX xx/xx/xx * * * *

this is the basic layout of the data once the code has run. the headers across are constant, the amount of clients going down is not unlimited however it could range from just 5 or 6 to 30 - 40, but never more than that.

Thanks again for your response ...

Mark
Feb 22 '07 #7
willakawill
1,646 Top Contributor
Then, perhaps, a listbox or datagrid would be a better tool for you
Feb 22 '07 #8
markryan57
21 New Member
Yes agreed,

I am looking into flexgrid now, what I have thus far will work temporarily, I just need to find a flexgrid solution before too long...

thanks so much for your time

Mark
Feb 22 '07 #9

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

Similar topics

7
3562
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some controls on the forms, and display these
7
1952
by: pizzy | last post by:
PROBLEM: I CAN'T GET THE LAST RESUTS TO WORK CORRECTLY. I WOULD PROVIDE THE CODE (AND WILL IF REQUESTED). BUT IN MY OWN WORDS I AM TRYING TO HAVE THE FIRST FORM DYNAMICALLY CREATE INPUT BOXES BASED ON THE NUMBER ENTERED. THEN ON THE SECOND FORM (WHICH IS CREATED BY THE FIRST FORM CALLING A FUNCTION) I WANT THE USER TO BE ABLE TO CLICK ON ONE OF THE CHECKBOXES AND SEE MORE INPUT BOXES APPEAR. HAS ANYONE DONE SOMETHING LIKE THIS? IF SO,...
5
8830
by: hzgt9b | last post by:
Is it possible to dynamically add controls (speciifcally System.Windows.Forms.ProgressBar and System.Windows.Forms.Label) to a panel to a form and have them display (and fucntion) at run time? I've been trying todo this by creating arrays of progressbars and labels. Then for each item in the root nods of a treeView that I need to track progress on, I create a bar and label and add them to a panel. The problem is that when I display the...
1
17673
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
1
1827
by: Mike Collins | last post by:
I have a web form that has most of the UI designed. On this form, some of the labels, textboxes, dropdowns, etc. will be added dynamically, depending on what extra bits of data the user decides they want to see. The question I have is when retrieving the dynamic fields for my form, should I get everything in one grab (dynamic fields and data) or keep the form dataset separate from the actual data dataset? Also, please excuse my ignorance,...
0
1548
by: Steve Funk | last post by:
All, I have searched all around and have not yet found the answer to this nor a solution. Hopfully it will be easy to overcome. Here is what I am trying to do: I'm trying to build a wizard form completely dynamic. I'm adding the labels, textboxes, drop downs, radio buttons, etc dynamically. I am able to add them via Page Init. Which seems to re-add every time a button or post back is initiated. Don't know if this is the problem.
2
1272
by: anniejacob | last post by:
hi, I am making a dynamic form which i have to put some labels which r 2 b dynamic.n i have to make 'n' number of labels dynamically. label me = new label(); This is the line im using to make it. how do i pass the value of 'n' in the code. if someone can help me 2 do this.
2
2139
by: prokopis | last post by:
am using c# for windows applications. am using dynamic linklayer array to print some labels in the form.i get some data from the database i add them in the linklabel array and i print it on the screen. my problem is how to make that linklabel to work when i select the label.am using the code below but is not working:) public class Form1 : Form { System.Windows.Forms.LinkLabel linklabel;
4
1852
by: libish | last post by:
hi all... can any one help me by suggesting a way to get items in dynamic form? here what i'm doing is , i'm displaying a dynamic form. in that form i have a main menu and this main menu contains a menu item "OK". here the dynamic form consist of some labels, list items and all. when i click on the "OK" menu item, an event occurs and i've wrote methods which wll execute on this event. now i need the selected list item index,value.. label...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.