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.
1 1544
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.
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...
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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):
_...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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"...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| | |