473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I restrict a user to enter a parameter in a list of values ?

Hi. A newbie question, please:

I have a function which gets some values from a database, based on a
CategoryName. My function looks like this:
Public Function GetProducts(ByV al CategoryName As String) As DataSet.

I would like to be able to restrict the user to enter only one of the
EXISTING categories - to behave in the same way IntelliSense behaves. For
instance if I had the categories "Category One" and "Category Two", the user
should only be able to select among one of those.

I created a module named "categories " with the intent to be able to declare
the function as
Public Function GetProducts(ByV al CategoryName As CategoriesList) As DataSet

I cannot use an enum, because I cannot enter the string "Category One" as a
valid member of the Enum (the name of the member has to be a valid VB name).

So I thought I could use a collection. I have now in a module named
"Categories .vb" a collection "CategoriesList ":

Module Categories
Public CategoriesList As New Collection()
End Module

CategoriesList is filled like this:

Do While objDataReader.R ead()
Categories.Cate goriesList.Add( objDataReader(" CategoryName"). ToString)
Loop

Now my problem is how do I change the signature of my function ? If I try to
write:
Public Function GetProducts(ByV al CategoryName As CategoriesList) As
DataSet, it says that CategoriesList is not defined as a type.

What am I doing wrong, please ?

Thank you, Alex
Nov 21 '05 #1
1 1113
Use combobox and set its dropdown property to dropdownlist. now pass
combobox1.text as string to the function :)
"Alex Nitulescu" <RE************ ***********@yah oo.com> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
Hi. A newbie question, please:

I have a function which gets some values from a database, based on a
CategoryName. My function looks like this:
Public Function GetProducts(ByV al CategoryName As String) As DataSet.

I would like to be able to restrict the user to enter only one of the
EXISTING categories - to behave in the same way IntelliSense behaves. For
instance if I had the categories "Category One" and "Category Two", the
user should only be able to select among one of those.

I created a module named "categories " with the intent to be able to
declare the function as
Public Function GetProducts(ByV al CategoryName As CategoriesList) As
DataSet

I cannot use an enum, because I cannot enter the string "Category One" as
a valid member of the Enum (the name of the member has to be a valid VB
name).

So I thought I could use a collection. I have now in a module named
"Categories .vb" a collection "CategoriesList ":

Module Categories
Public CategoriesList As New Collection()
End Module

CategoriesList is filled like this:

Do While objDataReader.R ead()
Categories.Cate goriesList.Add( objDataReader(" CategoryName"). ToString)
Loop

Now my problem is how do I change the signature of my function ? If I try
to write:
Public Function GetProducts(ByV al CategoryName As CategoriesList) As
DataSet, it says that CategoriesList is not defined as a type.

What am I doing wrong, please ?

Thank you, Alex

Nov 21 '05 #2

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

Similar topics

4
2187
by: Vijay Kumar R Zanvar | last post by:
Greetings, Are the following inferences of mine correct? 1. #include <string.h> char *strcpy(char * restrict s1, const char * restrict s2); a. s1 != s2 b. That means,
7
2669
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory location(s) pointed to, so that only one declared pointer can store that address and access the data in those memory blocks, where I the data in those location(s) can be changed. Is that a correct understanding?
6
3738
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many user get used to click "enter" key to submit a form. How can I use "enter" key to submit/postback in ASP.NET. Thank, Guoqi Zheng
12
2064
by: sam | last post by:
hi all, i'm starting to put together a program to simulate the performance of an investment portfolio in a monte carlo manner doing x thousand iterations and extracting data from the results. i'm still in the early stages, and am trying to code something simple and interactive to get the percentages of the portfolio in the five different investment categories. i thought i'd get in with the error handling early so if someone types in...
3
4386
by: %NAME% | last post by:
Suppose I am an admin of a database instance. Now I need to specify that user A has the right to create tables in his own schema, but not anywhere else. In order to let user A create tables, i grant createtab to that user. However, that would enable the user to create tables in other schemas as well (except those sys schema). Any way to restrict the users from creating objects in other schema than their own?
1
1924
by: =?Utf-8?B?Qw==?= | last post by:
I want to restrict the user entering nonalphanumeric keys using Javascript onKeypress. One exception is that I want to allow the user to enter spaces. How can I do this? Thanks in Advance.
5
8224
by: Dakrat | last post by:
Allow me to preface this post by saying that this is my first database project, and while I have learned a lot, any concepts I have learned are hit and miss as I have found new requirements and researched solutions. That said, I have a "training" database with PowerPoint briefings which I have users access and complete training. The form then records the date and time they completed training in a relevant field. I have a separate "master"...
3
1659
by: geebanga88 | last post by:
HI i want to create a month query that restricts the records by a month given that is inputed by a user from a form. There is an attribute in the relation called date which should only match the month date given by the user. What clause would i enter to get this restriction? i believe it has somthing to do with a date function? but im still unfamilar with it. I would also like to know which what is the best way to ask the user for a month...
2
2056
by: anwest75 | last post by:
Hi, I'm not a newb to Access but have recently migrated to 2007 and suddenly my method doesn't seem to work. I'm generating a service award report where I need to show only those employees hitting a milestone during a certain period of time. I've had Access calculate the appropriate milestone date, and now I want to pull only those records where the milestone date is within a range of dates that the user enters. Here is an example of my WHERE...
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.