473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Encounter error when setting properties value for a field in a loop

3 New Member
Hi,

I encountered an error "Object not supporting this properties or method" while trying to set a checkbox value to 'True" in a loop. The VBA code I use is as follow:

Set a value to intcount (say set intcount to 2)

ME("FieldName" & intcount).Properties.Value = True

increment intcount by 1 and loop back to set another checkbox value to True base on some conditions.

If I use Me.FieldName2.Value = True, this is accepted. But I need to use a loop to set the value base on some conditions as there are a lot of checkboxes to handle.

Can somebody points out what is wrong with the above codes?

Thanks very much for your help.

BL
Nov 21 '08 #1
3 1626
missinglinq
3,532 Recognized Expert Specialist
Look at the two pieces of code:

Doesn't work

ME("FieldName" & intcount).Properties.Value = True

Works

Me.FieldName2.Value = True

What's really different?

You've added an inappropriate Property to your first statement.

ME("FieldName" & intcount).Properties.Value = True

should be

ME("FieldName" & intcount).Value = True

without the "Properties."

Welcome to Bytes!

Linq ;0)>
Nov 21 '08 #2
MikeTheBike
639 Recognized Expert Contributor
Hi,

I encountered an error "Object not supporting this properties or method" while trying to set a checkbox value to 'True" in a loop. The VBA code I use is as follow:

Set a value to intcount (say set intcount to 2)

ME("FieldName" & intcount).Properties.Value = True

increment intcount by 1 and loop back to set another checkbox value to True base on some conditions.

If I use Me.FieldName2.Value = True, this is accepted. But I need to use a loop to set the value base on some conditions as there are a lot of checkboxes to handle.

Can somebody points out what is wrong with the above codes?

Thanks very much for your help.

BL
Hi

On the basis that 'FieldName2' is the name of the field that is bound to a CheckBox control of the same name, then any of these will set it to yes/true

[FieldName2] = True

FieldName2.Value = True

Me.Controls("FieldName2") = True

Dim intcount As Integer
intcount = 2

Me.Controls("FieldName" & intcount) = True


I think it is the last one you are looking for !?



MTB
Nov 21 '08 #3
BL3WC
3 New Member
Hi

On the basis that 'FieldName2' is the name of the field that is bound to a CheckBox control of the same name, then any of these will set it to yes/true

[FieldName2] = True

FieldName2.Value = True

Me.Controls("FieldName2") = True

Dim intcount As Integer
intcount = 2

Me.Controls("FieldName" & intcount) = True


I think it is the last one you are looking for !?



MTB
Thanks Linq and MTB for your answer. I now have the correct setting in my application.

I am quite new to the Access VBA syntax and got a bit consfued with the various syntax you suggested.

1. Why do some codes use the following syntax:
"FieldName.Properties("Value") = xxx" instead of directly use the syntax "FieldName.Value = xxx"?

2. Are there situations that one should use the first one instead of the other?

3. What are the valid situations to add ".Control" before the field name?

Thanks again for your reply.
BL
Nov 21 '08 #4

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

Similar topics

2
by: sparks | last post by:
I was going to loop thru the tables and change some properties. 10 <<<<<< prp.value --prp.name = Type False <<<<prp.value --prp.name = allow zero length 10 <<<<<< prp.value --prp.name = Type...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
0
by: scpedicini | last post by:
Okay, I've been having a problem with custom design-time properties that has been driving me nuts for about a week. The control that I'm working on extends System.Windows.Forms.AxHost, but I'm...
1
by: simon | last post by:
I have an unbound RTF2 control in an Access 2003 form which I set to show either unformatted text or else text with words and sentences highlighted. I do this by setting the PlainText property,...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
1
by: prakz | last post by:
<% ' ------------------------------------------------------------------------------ ' Container of Field Properties Class clsField Public FileName Public ContentType Public Value Public...
7
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
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
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
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...
1
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
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
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.