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

Need help with Index

11
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?
Feb 3 '12 #1
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.
Feb 3 '12 #2
Smecker
11
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.
Feb 3 '12 #3
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.
Feb 4 '12 #4
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim strWhere As String
  3.  
  4. If IsNull(Me![txtLoginID]) Or IsNull(Me![txtStatus]) Then
  5.   MsgBox "Both the Login ID and Status Fields are required!"
  6.     Cancel = True
  7. Else
  8.   'Do not allow Duplication on 'ACTIVE' Accounts for the same Login ID, but
  9.   'allow Duplication on the ID for 'TERMED Accounts
  10.   If Me![txtStatus] = "ACTIVE" Then
  11.     strWhere = "[LoginID] = '" & Me![txtLoginID] & "' AND [Status] = '" & _
  12.                 Me![txtStatus] & "'"
  13.       If DCount("*", "tblUserInfo", strWhere) > 0 Then
  14.         MsgBox "You cannot have the same ACTIVE, Login IDs"
  15.           Cancel = True
  16.       End If
  17.   End If
  18. End If
  19. End Sub
Feb 5 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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);
2
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;
13
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...
8
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...
3
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...
1
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...
2
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...
4
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 ...
2
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...
1
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
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?
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
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
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...

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.