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

access 2003 form to count fields with data

I have 7 fields to key to on a form. Is there a way to count the number
fields that have for example, a value greater than zero?

Feb 22 '06 #1
3 5466
cd*******@alltel.net wrote:
I have 7 fields to key to on a form. Is there a way to count the number
fields that have for example, a value greater than zero?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In a Command Button's click event, something like this:

dim ctl as control
dim i as integer

for each ctl in me.controls
If Not IsNull(ctl) Then
if isnumeric(ctl) then
if ctl.value > 0 then i = i + 1
endif
endif
next ctl

debug.print "Controls > 0: " & i

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ/zlI4echKqOuFEgEQIDUgCeOZhdKb9rPjQym+MEYqXWjawIhD4A oMax
0lf2O0LvePL0BQUUBkrgoeJX
=aqUt
-----END PGP SIGNATURE-----
Feb 22 '06 #2
I have three fields before the seven mentioned and one field after. Is
there a way to just look at the middle seven fields. Also, can this be
applied to a continuous form?

Feb 23 '06 #3
cd*******@alltel.net wrote:
I have three fields before the seven mentioned and one field after. Is
there a way to just look at the middle seven fields. Also, can this be
applied to a continuous form?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To run on selected controls you'd have to name them something like this
"Control_1" "Control_2", etc., and iterate thru them like this:

dim j as integer

for j = 1 to 7
set ctl = Me("Control_" & j)
If Not IsNull(ctl) Then
if isnumeric(ctl) then
if ctl.value > 0 then i = i + 1
endif
endif
next i

Instead of iterating thru the controls of each record on a continuous
form you shud just query the table(s) that supply the recordset to the
form. E.g.:

SELECT Count(IIf(IsNumeric(colA),1,NULL))
+ Count(IIf(IsNumeric(colB),1,NULL))
+ Count(IIf(IsNumeric(colC),1,NULL)) As NotNullColumns
FROM table_name
WHERE colA > 0 OR ColB > 0 OR ColC > 0

This is a kludgey query. The problem w/ this is really a DB design
issue -- the data types of each column should be strictly enforced.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ/40B4echKqOuFEgEQJwzwCfZW/hqZfMecyQ7wnDAcAZMJjA5TAAnRJf
TZa/daV8X7cJb1NJd9zRisMU
=C/lY
-----END PGP SIGNATURE-----
Feb 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
1
by: nfrodsham | last post by:
In Microsoft's help literature, it states: "You can filter out non-unique rows by using the DISTINCT option of an aggregate function" I am trying to do this in Access 2003 with the COUNT...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: CheshireCat | last post by:
I have added an access database into my 2005 desktop project, created a dataset called ResourcesDataSet which contains one of each table in the database using the wizard. The database was...
1
by: il0postino | last post by:
Apologies in advance for this newbie question! I have an Access form with an unbound embedded Excel chart on it(Called, OLEUnbound39) (Done on Access form by Insert > Object > Microsoft excel...
2
by: steph | last post by:
I have a table with 250 fields. Of course you are wondering why 250 fields... what could I possibly be storing in so many fields? I am using this table as a general import table for files that...
12
by: tekctrl | last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access 2002 Issue; Access presents a blank data entry form in the Forms view when the New Record icon is used. However, it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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...

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.