For tina ([email protected]), or Access expert- Forms

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Hi tina,

You had replied to my question on Friday, on how to search
whether a particular record (organization name) is already
in a database. You mentioned that one of the ways to do it
is to have a comboBox with the list of organizations, and
then use the 'NotInList' property to enter a new
organization.

My question is this: Is this the only way to do it? I'd
like to have the user type in a name in a textbox using a
form (instead of look it up in a combo box) and then
search the table for that value entered. Is this more
complicated to implement than what you suggested?

Thanks for your help.

-Amit
 
-----Original Message-----
Hi tina,

You had replied to my question on Friday, on how to search
whether a particular record (organization name) is already
in a database. You mentioned that one of the ways to do it
is to have a comboBox with the list of organizations, and
then use the 'NotInList' property to enter a new
organization.

My question is this: Is this the only way to do it? I'd
like to have the user type in a name in a textbox using a
form (instead of look it up in a combo box) and then
search the table for that value entered. Is this more
complicated to implement than what you suggested?

Thanks for your help.

-Amit
.
Create a blank form and add a text box with a caption like
Enter Organization Name
under the properties all tab name the txtbox TxtOrg
Save the form as Frm_NewOrg
create an append query using the table with the org names
in the criteria under the name field
type
[Forms]![Frm_NewOrg]![TxtOrg]
on the menu bar under query - parameters enter the same
information.
create a macro
1st line: setwarnings no
2nd line: openquery (the above query)
3rd line: setwarnings yes
4th line: close (Frm_NewOrg)

On your Frm_NewOrg create a button and run the above macro
from it.
This will add the Oranization to the table if it is not
there an if it is there already it will not add it if the
organization name in your table is set either as your
primary key or is indexed to yes (No Duplicates)
You can use any name you want for the above. I just gave
those names for ease in explaining.
 
Amit,

Regarding:
type in a name in a textbox using a
form (instead of look it up in a combo box)

I think you misunderstand the use of the Combo Box in this situation.
A Combo Box is a control on your form.
It contains the names of every organization already in the database.
The user doesn't have to 'look' for the actual name, just start
typing the name.
As each additional letter is typed, the combo will jump to the first
name that starts with those letters.
If there is only one organization that start with the letters 'lea'
(i.e. Leadership for Young Adults) then as soon as the letters
'lea' are entered the 'Leadership for Young Adults' name will appear.

Use the wizard to make the combo box and fill it with the names.
Make sure that the combo Box's AutoExpand property is
set to Yes, and the LimitToList property is also Yes.

Otherwise, you can use a regular unbound text control.
Set it's AfterUpdate event to:
If DCount("*", "OrganizationTable","[OrganizationName] = '" & Me!ControlName
& "'") > 0 Then
MsgBox "This organization already exists in the table"
End If

You'll have to correctly spell the full name of the organization.

Certainly you will agree typing 3 letters to find the organization is
more efficient than typing 27.

Then what are you going to do with the information that the organization
exists?
 
Back
Top