473,409 Members | 1,942 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,409 software developers and data experts.

Displaying labels and checkboxes at runtime, but getting errros

1
Hello,

I am trying to display, on an MS Access form (frm024), the contents of a table (tbl_TypeOfOrgs). The table has two fields, OrgTypeID and OrgType. It currently has 4 records. This table could expand or shrink.

The OrgType field needs to be displayed on a form (frm024, as Labels) along with checkboxs next to them. When completing the form, the user will select the appropriate checkboxes.

Now, because this table could be expanded (or shrunk) I need to be able to dynamically create the labels and checkboxes at runtime. Then when a save button is hit on the form another table will be updated with the OrgTypeID (and the OrgID, which is already on the form).

My problem is that I can't get the the labels to show on the form. I get an 'ActiveX component can't create object' error.

The code I have is as follows:

========================================

Private Sub btn033_Click()
On Error GoTo Err_btn033_Click

DoCmd.OpenForm "frm027"

Dim conn As ADODB.Connection, rcd1 As New ADODB.Recordset
Dim intCountRecords As Integer
Set conn = CurrentProject.Connection
rcd1.Open "tbl_TypeOfOrgs", conn, adOpenKeyset, adLockOptimistic
intCountRecords = rcd1.RecordCount

MsgBox intCountRecords

rcd1.MoveFirst
Dim Label1() As Label
ReDim Label1(intCountRecords)

Dim Text1() As TextBox
ReDim Text1(intCountRecords)

Dim i As Integer
For i = 1 To intCountRecords ' the number of names you have
MsgBox i
Text1(i) = New TextBox
'Load Text1(I)

'Label1(I) = New Label
'Load Label1(I) = New Label

'Text1(I).Visible = True
'Label1(I).Visible = True
'Label1(I).Top = Label1(I - 1).Top + Label1(I - 1).Height + 100
'Text1(I).Top = Text1(I - 1).Top + Text1(I - 1).Height + 100
'Text1(I).TabIndex = Text1(I - 1).TabIndex + 1
Next i



Exit_btn033_Click:
Exit Sub

Err_btn033_Click:
MsgBox Err.Description
Resume Exit_btn033_Click
End Sub

===========================================

Apologies for the commented out code, I have tried numerous ways having looked all over the net. But to no avail.

The 'MsgBox i' line is showing that the code is breaking here.

Please help before I lose all my hair!!!!

I am running Access 2000 and MS VB 6.3, and am exremely new to this language.

Thanks in anticipation.
May 23 '07 #1
1 1544
Dököll
2,364 Expert 2GB
Hello,

I am trying to display, on an MS Access form (frm024), the contents of a table (tbl_TypeOfOrgs). The table has two fields, OrgTypeID and OrgType. It currently has 4 records. This table could expand or shrink.

The OrgType field needs to be displayed on a form (frm024, as Labels) along with checkboxs next to them. When completing the form, the user will select the appropriate checkboxes.

Now, because this table could be expanded (or shrunk) I need to be able to dynamically create the labels and checkboxes at runtime. Then when a save button is hit on the form another table will be updated with the OrgTypeID (and the OrgID, which is already on the form).

My problem is that I can't get the the labels to show on the form. I get an 'ActiveX component can't create object' error.

The code I have is as follows:

========================================
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn033_Click()
  2.     On Error GoTo Err_btn033_Click
  3.  
  4.     DoCmd.OpenForm "frm027"
  5.  
  6.     Dim conn As ADODB.Connection, rcd1 As New ADODB.Recordset
  7.     Dim intCountRecords As Integer
  8.     Set conn = CurrentProject.Connection
  9.     rcd1.Open "tbl_TypeOfOrgs", conn, adOpenKeyset, adLockOptimistic
  10.     intCountRecords = rcd1.RecordCount
  11.  
  12.     MsgBox intCountRecords
  13.  
  14.     rcd1.MoveFirst
  15.     Dim Label1() As Label
  16.     ReDim Label1(intCountRecords)
  17.  
  18.     Dim Text1() As TextBox
  19.     ReDim Text1(intCountRecords)
  20.  
  21.     Dim i As Integer
  22.     For i = 1 To intCountRecords ' the number of names you have
  23.         MsgBox i
  24.         Text1(i) = New TextBox
  25.         'Load Text1(I)
  26.  
  27.         'Label1(I) = New Label
  28.         'Load Label1(I) = New Label
  29.  
  30.         'Text1(I).Visible = True
  31.         'Label1(I).Visible = True
  32.         'Label1(I).Top = Label1(I - 1).Top + Label1(I - 1).Height + 100
  33.         'Text1(I).Top = Text1(I - 1).Top + Text1(I - 1).Height + 100
  34.         'Text1(I).TabIndex = Text1(I - 1).TabIndex + 1
  35.     Next i
  36.  
  37.  
  38.  
  39. Exit_btn033_Click:
  40.     Exit Sub
  41.  
  42. Err_btn033_Click:
  43.     MsgBox Err.Description
  44.     Resume Exit_btn033_Click
  45. End Sub
  46.  
===========================================

Apologies for the commented out code, I have tried numerous ways having looked all over the net. But to no avail.

The 'MsgBox i' line is showing that the code is breaking here.

Please help before I lose all my hair!!!!

I am running Access 2000 and MS VB 6.3, and am exremely new to this language.

Thanks in anticipation.
Perhaps this will not solve the problem you are having, looks like a nicely written code. But the only thing I see is that you dimensioned Text1(), and have it set to relay a loop as i, but are loading it as 'Load Text1(I)

Looks like the application is looking for i...
Jun 3 '07 #2

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

Similar topics

3
by: Mark C | last post by:
When aspx pages are made in vs.net, loading on the local host displays the labels all in the top left corner of the screen. Also, all textboxes and image buttons are not even displayed at all. If...
11
by: Jamie Jackson | last post by:
Two part question: 1) I'd like to do have nicely indented checkbox labels, even where wraps occur (for instance, the way <li> wrapping works). So, I'd like this (where "_" = checkbox): _...
7
by: Jared | last post by:
Here is my situation. I have multiple labels on a form but only certain ones will become visible while using the form. Depending on which check box(s) you pick, on another form, determines the...
3
by: Kidus Yared | last post by:
I am having a problem displaying Unicode characters on my Forms labels and buttons. After coding Button1.Text = unicode; where the unicode is a Unicode character or string (‘\u1234’ or...
7
by: eBob.com | last post by:
Despite my bad cold and headache I should be able to correctly code what I am trying to code below. Or should at least be able to determine why such simple code does not work. I do have very...
24
by: Mike Otten | last post by:
Any help greatly appreciated. The validated page is at: http://myweb.stedwards.edu/michaelo/ddtab.htm The trouble is with the radio buttons (2/3-down the left column). The radios are...
0
by: Charles Krug | last post by:
List, I'd like to do the following with Tkinter's Frame() object: 1. Display a collection of pack()-able objects. Easy. Done. I hold the objects in a dictionary, mostly so that the owning...
0
by: darrel | last post by:
Hi there, good day! i need some help in displaying my records,,, my assignment is i have to display a database records in a labels. Its like this in my database i have a table called "SUBJECTS"...
6
by: Richard Hollenbeck | last post by:
Thanks to everybody who has helped me to get this thing finally working (somewhat). I got the field names to properly display in the PageHeaderSection, so I won't post the code from that. Now I'm...
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
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
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...
0
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
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...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.