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

How to test the contents of a field or control?

Hi,

I want to be able to loop through all the controls on a form, get
their names, and then check if they contain a date, number, or string.

Is there a function to test the contents of a field or control? I am
using Access 2003.

Thanks

-pw

use paulwilliamson at spamcop dot net for e-mail
Nov 13 '05 #1
4 1207
something like...
From INSIDE your form.


dim ctl as control
dim ctlType as string

for each ctl in Me.Controls
if isdate(ctl.Value) then
ctlType = "Date"
else if isNumeric(ctl.Value) then
ctlType="Number"
else if istext(ctl.value) then
ctlType="text"
end if
debug.print ctl.name " contains a " & ctlType & " value."
next ctl

or something like that...
Kinda seems weird to do this unless your controls are unbound,,, is
there a reason for this?

Nov 13 '05 #2
On 23 Aug 2005 16:23:13 -0700, pi********@hotmail.com wrote:
something like...
From INSIDE your form.


dim ctl as control
dim ctlType as string

for each ctl in Me.Controls
if isdate(ctl.Value) then
ctlType = "Date"
else if isNumeric(ctl.Value) then
ctlType="Number"
else if istext(ctl.value) then
ctlType="text"
end if
debug.print ctl.name " contains a " & ctlType & " value."
next ctl

or something like that...
Kinda seems weird to do this unless your controls are unbound,,, is
there a reason for this?


Thanks! isDate, isNumeric, and isText are inherent in Acess 2003? I
can't find them in the help or my books. They must be a user function
(which is what I am asking help for)?

What I am going to do is build SQL Where clauses from a form where the
user can pick any combination of fields that are on the unbound form
and display the results, print mailing labels, e-mails, export to a
text file, etc..... It's actually a very powerful feature for our
lodge software. It's pretty slick, if I don't mind saying so myself
<BG>. Now I am "stealing" my own code for another application of mine.
I've done it before with A97 but I want to spiff up my old code.

So... I need to find out what type of variable (what text box,... or
whatever the user filled in) I have so I can satisfy Jet with it's
"crazy" syntax :-) I just can't my brain to absorb the rules!

Thanks!

-pw

use paulwilliamson at spamcop dot net for e-mail
Nov 13 '05 #3
Try looking at Help from the module Window. Many functions are documented
only in VBA Help, even some that are usable in Access' expressions.

Larry Linson
Microsoft Access MVP

<pa******************@removespamcop.net> wrote in message
news:aq********************************@4ax.com...
On 23 Aug 2005 16:23:13 -0700, pi********@hotmail.com wrote:
something like...
From INSIDE your form.


dim ctl as control
dim ctlType as string

for each ctl in Me.Controls
if isdate(ctl.Value) then
ctlType = "Date"
else if isNumeric(ctl.Value) then
ctlType="Number"
else if istext(ctl.value) then
ctlType="text"
end if
debug.print ctl.name " contains a " & ctlType & " value."
next ctl

or something like that...
Kinda seems weird to do this unless your controls are unbound,,, is
there a reason for this?


Thanks! isDate, isNumeric, and isText are inherent in Acess 2003? I
can't find them in the help or my books. They must be a user function
(which is what I am asking help for)?

What I am going to do is build SQL Where clauses from a form where the
user can pick any combination of fields that are on the unbound form
and display the results, print mailing labels, e-mails, export to a
text file, etc..... It's actually a very powerful feature for our
lodge software. It's pretty slick, if I don't mind saying so myself
<BG>. Now I am "stealing" my own code for another application of mine.
I've done it before with A97 but I want to spiff up my old code.

So... I need to find out what type of variable (what text box,... or
whatever the user filled in) I have so I can satisfy Jet with it's
"crazy" syntax :-) I just can't my brain to absorb the rules!

Thanks!

-pw

use paulwilliamson at spamcop dot net for e-mail

Nov 13 '05 #4
Try looking at Help from the module Window. Many functions are documented
only in VBA Help, even some that are usable in Access' expressions.

Larry Linson
Microsoft Access MVP


That was it Larry! Thanks!

-paul
-pw

use paulwilliamson at spamcop dot net for e-mail
Nov 13 '05 #5

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

Similar topics

2
by: Dave Griffiths | last post by:
Access 97 - I have a form with a single unbound text field. I want to have a timer event which periodically saves the contents of that field. But I noticed that if the focus stays on the field then...
2
by: Keith Wilby | last post by:
A2003, XP Pro. I have a text box on a form. The text box is bound to a hyperlink field. I want to use the contents of the text box in code so I'm assigning the contents to a string variable. ...
8
by: AA Arens | last post by:
I have a Notes block and have to buttons to have the cusror moved to the top as well as the bottom of the contents. Here is the VB of the buttons: To top: Notes.SelStart=0 To bottom:...
4
by: Kuldeep | last post by:
Hi All, I am trying to read the contents of a page through its URL. My code snippet is as follows: public void mtdGetPageDataHWR() { HttpWebRequest objRequ =...
1
by: Fretners | last post by:
I have a form that displays the contents of a table. I want to be able to apply filters though the form and then base an insert query on the filtered data to create a new row to match each row in...
1
by: --== Alain ==-- | last post by:
Hi, I have a huge problem... My property does not appear in the "propertyGrid" of "test Container", when i test my custom control. Here is the custom control code : namespace...
2
by: DeanL | last post by:
Hi guys, I'm using a subform to display a list of values from a single table. The form is showing the values in "continuous forms" view and there will only ever be two different values for the...
2
by: Peted | last post by:
Hi if i derive a reference to a control on a winform (ie Control activeControl = somecontrol on the form) how can i test if that control has a validating or validated event and more importantly...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.