I'm working on a database to store user information for an application at work. It contains the user's name, email, etc and login information. Login IDs are 4 numbers and 2 letters (like 1234AB). The way this particular application works is when an account is disabled the login ID is deleted from the system. This means that sometime in the future it would be possible for the same number/letter combo to be created later attached to a different user account. I have a field in the DB for loginID and another for Status (ACTIVE or TERMED are the options). I'd like to be able to setup an index so that active accounts can't be duplicated, but doesn't care about termed accounts being duplicated. Is this possible in Access?
4 1198 NeoPa 32,556
Expert Mod 16PB
You could set up a unique index consisting of both the [LogonID] and the [Status] fields. This would allow the same [LogonID] value in an ACTIVE record as another in a TERMED record. Notice the an though. It would not allow multiple TERMED records with the same [LogonID]. Even though you didn't specify this as a requirement, I suspect it is.
An alternative (not a good one I don't believe) is to copy the TERMED records into a separate table. Nasty idea. Don't do it.
Otherwise you can manage it yourself without specifying the index be unique.
Thanks, NeoPa. That's what I was thinking, and you're right about the options not being very good. I was wondering, is it possible to make a validation rule on the [LoginID] field to check for duplicates based on status? This would remove the index issue.
NeoPa 32,556
Expert Mod 16PB
I'm pretty sure the validation rule has no access to other data in the dataset, so I'm guessing that won't work.
Not sure if the following would be appropriate in your case, but if you wished to Drop the Index, you could Validate User Input in the BeforeUpdate() Event of your Form. The following Code will NOT allow Duplication on ACTIVE Accounts for a specific Login ID, but will for TERMED: -
Private Sub Form_BeforeUpdate(Cancel As Integer)
-
Dim strWhere As String
-
-
If IsNull(Me![txtLoginID]) Or IsNull(Me![txtStatus]) Then
-
MsgBox "Both the Login ID and Status Fields are required!"
-
Cancel = True
-
Else
-
'Do not allow Duplication on 'ACTIVE' Accounts for the same Login ID, but
-
'allow Duplication on the ID for 'TERMED Accounts
-
If Me![txtStatus] = "ACTIVE" Then
-
strWhere = "[LoginID] = '" & Me![txtLoginID] & "' AND [Status] = '" & _
-
Me![txtStatus] & "'"
-
If DCount("*", "tblUserInfo", strWhere) > 0 Then
-
MsgBox "You cannot have the same ACTIVE, Login IDs"
-
Cancel = True
-
End If
-
End If
-
End If
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andy |
last post by:
a new user of oracle 10g.
tried the following statements on scott/tiger with tablespace x
create table mytest (
a varchar2(30)
);
alter table mytest
add constraint pk_a primary key(a);
|
by: Luigi Napolitano |
last post by:
Hello,
I use this algorithm to sort an array "v" in the descending order.
void quickSort(float v, int lo0, int hi0)
{
int lo = lo0;
int hi = hi0;
if (lo >= hi) return;
float mid = v;
|
by: LUIS FAJARDO |
last post by:
I have the following sintax:
Select *
From Inventory
Where PartId = Coalesce(v_PartId, PartId)
this type of query is used within an store procedure that provide the
v_PartId parameter, the...
|
by: John Baima |
last post by:
I have an Access table that just consists of 2 columns: WordID
(Autonumber, Primary key) and WordText (Text, Indexed, No dups). I've
used this with a number of texts and languages without any...
|
by: RBohannon |
last post by:
I'm using Access 2000.
I've written a function, blnExists(), to check if a particular value
exists in the primary key field of a table. blnExists returns true if
the value is in the table and...
|
by: techfuzz |
last post by:
I'm posting my problem experience and solution I found here for other
ASP.NET developers.
I have a web application that uses Forms Authentication with Active
Directory to control access. In...
|
by: Kent P. Iler |
last post by:
Hi,
I am building my first ASP.NET website (I've done quite a few in ASP with
windows DNA, but none needing Index server).
I need to have a site search, and want the results formatted in a...
|
by: Jorge Varona |
last post by:
Greetings,
I am having a difficult time trying to get my index server query to work.
Here's the code:
// create a connection object and command object, to connect the Index
Server
...
|
by: Dámaso Velázquez Álvarez |
last post by:
Hi!
I am working with mysql server 5.0 an I have an Index in a database
table,
but I need to index the word 'once'. My index it's not indexing it
because once is a number... How can I...
|
by: w33d5 |
last post by:
I'm looking for a little help in making an index file to read the subdirectories in the same folder and display the links in a table.
i am loading photo galleries using google's picasa onto my...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
| |