473,487 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Create 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 2504
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
3485
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)...
7
1921
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...
5
8807
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? ...
1
17625
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...
1
1798
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...
0
1532
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...
2
1255
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...
2
2123
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...
4
1834
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...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5442
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,...
1
4874
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...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
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...

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.