Checking For Duplicate Numbers
Jan 31, 2006
I have a form in which new equipment is added. I want to be able to check when the ID number is added (first field on the form) that there is not a duplicate ID number. If I wait till the end of the form and save, then Access tells me that there is a duplicate present but by then I have spent time putting in all the rest of the data.
If have added this code in the before update section for the relevent field, but it doesn't seem to work. Can someone please help clarify or suggest an easier way
Dim IntIDCheck as integer
Dim Response
IntIDCheck = DCount("[EquipmentID]","Equipment Inventory","[EquipmentID] =" & Me.EquipmentID)
if IntIDCheck > 0 then
Response = MsgBox ("Duplicate Present")
Me.EquipmentID.SetFocus
Cancel = True
Exit Sub
End if
Thanks
View Replies
ADVERTISEMENT
Aug 21, 2006
I have a control called GoToId which afterupdate moves the user to a specified record where ID=GotoID. I want the control to only take numbers as input. I used input mask: 999999;;" " but with it the user can still press a letter on a keyboard and even though the letter doesn't get typed in, I think an empty string gets passed as value.
If I can't do it with masks, what's the simplest if statement in vba that will check if the value is a number and positive? (IF the value is Null, "", or anything else I want the if expression to be false)
I know how to do it with several if statements checking if is null, or if "", but there must be a clean way of asking it in a single expression.
View 3 Replies
View Related
May 10, 2005
Hi,
I have a form in a database for our products (doors). I have a button that duplicates one of these records (all new products are based on standard template records).
When this record is created a new product number is produced by the system which was the number of the original (template) record plus the customer enquiry number.
I want to be able to warn the user if they are trying to save this newly created record with a product number that already exists so that they can alter the number to be unique. It will also warn them if they re-number an existing record to another already existing product number. Since the field is defined as unique, at present the system says absolutely nothing and just doesn't save the newly created record which seems is a touch annoying!
I have tried several things with dlookup, dcount arguments but can't seem to get anything to work.
Hopefully someone here can point me in the right direction?
Thanks in advance
John
View 2 Replies
View Related
Dec 28, 2006
Hello,
I'm new to using VBA for MS Access. May I enlist your help, Please.
I'm working on a human resources database for a group of employees. I'm trying to automate their login process after they have opened the database so that each employee's privacy is respected. Using an initial form, employees are separated into "New User" or "Returning User". My problem concerns setting up the "New User" in the database.
The New User is directed to form "frm_NU". The form has several unbound fields which are later carried to the table "tbl_Employees". Two of the fields on the form are used to create the EmployeeID. Those are Initials [INI] and Phone Extension [EXT]. The EmployeeID will be used in a filter so that only that employee's information is made available to the user (simulated Privacy).
Because the employees are unfamiliar with MS Access and its cryptic error messages, I need to create a message box which will give a plain English warning when a user attempts to use an existing ID to create a new record. [EmployeeID] is a field in the table. it is set as a key and does not allow duplicates.
When a new user enters his/her initials and phone extension I want the new ID to be compared to the table and if found, a message should appear. This is a preemptive strike to prevent the user from getting to the more cryptic MS Access error message.
I've tried using Dlookup and Dcount to try to pass some meaningful data to the If statement variable VarX to trigger the message box; assuming that Varx should be something other than Null or Empty
Dim EmpID As Variant
Dim VarX As Variant
EmpID = [INI] & [EXT]
VarX = DLookup([EmployeeID], "qry_Employees", [EmployeeID] = [EmpID])
If VarX <Is Not Empty> Then
X = MsgBox("Another record already exists by that name", vbOKOnly)
Else
Y = MsgBox("Passed", vbOKOnly)
End If
I keep getting an error at the DLookup formula or DCount formula saying: Run-time error; 2001 You canceled the previous operation. It also appears that the DLookup never looks up anything nor does DCount count anything even though I'm purposely entering duplicate information which exists in "qry_Employees". I was expecting VarX to be either the duplicate ID or a record number or record count or something.
Any ideas or constructive suggestions?
Thanks,
Goh
View 4 Replies
View Related
Jun 29, 2013
What would be the Access 2007 VBA code for checking for duplicate records?
View 14 Replies
View Related
Jun 15, 2013
I'm using Access 2013. I want to check duplicate data. I have a form where from insert data into table but before insertion I want check multiple criteria with form. How can I do this
Field are:
BatchID
BillNum
CIH
IH
back end form code is:
Private Sub cmdCheck_Click()
Dim criteria As String
criteria = "[BatchID]=" & Me.cboBatchID & " AND [BillNum]=" & Me.txtBillNum & " AND [CIH]=" & Me.txtCIH & " AND [IH]=" & Me.txtIH & ""
[Code] ....
Finally I'm getting this error: Run Time Error 3075 Syntax Error Missing Operator in qry Expr.
View 3 Replies
View Related
Apr 11, 2014
Below is some code that I'm struggling with and I get an error message "Type Mismatch".
Description: The database contains multiple projects and the subset of each project is a release. The "PublishedNumber" can't be a duplicate within a release, but it can be a duplicate within the table where the data is stored. There can however be multiple occurrences of 0.
Here's my code:
Dim stLinkCriteriaRelease As String
Dim stLinkPublishedNumber As String
Dim DuplicateNumber As Variant
stLinkCriteriaRelease = "[AssociatedRelease]=" & [AssociatedRelease]
stLinkPublishedNumber = "[PublishedNumber]=" & [PublishedNumber]
[Code] ....
View 3 Replies
View Related
Jun 25, 2007
I've got an incrementing invoice number that is just a +1 of the last invoice number. Had a problem today where one user was creating an invoice and took a while to complete the record. As soon as the record was created the invoice number went in as 123 but the record didn't save until she had filled out all the form. In the meantime someone else started to create another invoice and ended up with 123 as well because the previous record hadn't saved. Does anyone have any suggestins how I can stop this from happening? I can't save the record straight away, which would be the obvious answer as they need to fill out quite a few required fields before the record is saved so that they don't have incomplete records.
Thanks
DBL
View 2 Replies
View Related
Nov 10, 2005
Hey
I currently have this code which tells the user there is a an accout number already on the db:
Private Sub AccountNo_AfterUpdate()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Select * From Spreadsheet where AccountNo = '" & Me.AccountNo & "';")
If rs.RecordCount > 0 Then
MsgBox "This Account Number Is Currently Within The Database And Will Not Be Allowed.", vbInformation, "DD Cancellations"
Me.AccountNo = Null
End If
End Sub
I want a peice of code which instead allocates a letter to the duplicate account, so user enters a duplicate account, the account will then turn into 123456789A, upto 5 duplicates are allowed, so upto 123456789E. Once "E" has been reached accountnum box will turn null with msgbox. I tried out Case statements but that doesn't seem to work.
all help appreciated. Thanks.
View 8 Replies
View Related
Sep 15, 2013
I have the following code and I am trying to show a COUNT of duplicate ID numbers, so for example
ID ID_COUNT
2000 2
2000 2
2001 1
2002 1
2003 1
Code:
SELECT [DaisyServiceData-Import].*, Companies.CompanyName, Company_vs_Services.[Tariff Code], IIf([ClashForce]=True,"",IIf([ClashOveride]=False And [ClashClear]=False,IIf([DaisyServiceData-ClashExc].[DaisyServiceData-Import].[ID] Is Null,"",1),"")) AS ClashExc, IIf([Sell Price]="","",IIf([SellRateForce]=True,"",IIf([CompanyName] Is Null,"",IIf([SellRateOveride]=False And [SellRateClear]=False,IIf([Total Cost]>[Sell Price]+0.001,1,""))))) AS SellRateExc, IIf([Tariff Code]='1',[T1Rate],
[Code] ...
A GROUP BY query will not work for me as the recordset needs to remain updatable.
View 2 Replies
View Related
Aug 12, 2014
I'm having multiple problems with my database like things such as -
i'm currently working on the Query 2 - On the Phone database (ignore Query 1) and i want to search for multiple plot numbers preferably in one parameter prompt with a comma to seperate numbers. (this could be a multitude of numbers so i would like to be able to input as many as needed). Also when i do search on this query since the Criteria is a 'Between' Value i would expect everything between the 2 numbers input to show up - but a lot of numbers out of the range show up too - why is this? (The Numbers are like "69 to 136" and they will show up - but 1-69 and 136-170 would too
I would also like to implement the search results from Query 2 into the Form i currently have made but it just opens up a access table when the search is made?
i cannot link my database as it is too big for the server - But here are the Criteria for Query 2:
Plot No - (criteria = Between [Enter First Plot No:] And [Enter Last Plot No:])
Site - (criteria = Like "*" & [Enter Site:] & "*")
Product - (criteria = Like "*" & [Enter Product:] & "*"
The Query is the one im most concerned about , i can live without a form.
View 14 Replies
View Related
Jan 10, 2007
Ok so in excel I have some numbers that are stored as text. The reason being that they are zip codes and some begin with 0 and excel doesn't want numbers to start with 0....so when I import these into an access field that has an input mask for zip codes...will it convert these correctly since the field is a text with input mask?
View 1 Replies
View Related
Aug 24, 2014
I have 2 fields that I would like to automate if possible
One field is called "p/o number" and another field called "line no"
These fields are part of an ordering database
Let say I have 200 items to purchase form 10 suppliers
And form example 20 items from each supplier
What I do at present is put the order number on each line item and the line number
example
p/o number line no
1 1
1 2
1 3
2 1
2 2
2 3
2 4
What I want to do is just put the first po number in the required line . Put the first line number in i.e. "1" and the macro will complete all the p/o numbers and line numbers for me as per the ones marked in red.
Example
1 1
2 2
3 3
2 1
2 2
2 3
View 5 Replies
View Related
Dec 30, 2013
We are working on an Access (2007) database that is on a SharePoint Site (2007).
Currently the form is operational, but there is one last thing that would be nice to have.
The table is "Updated Headcount" which contains "EMP_ID" which are unique numbers stored as text.
In the event a new employee is entered in the system by another user on this site we would like to prevent any duplicate "EMPID"s from being entered and saved on the SharePoint, we would also like to alert the user and prevent the data from being saved.
All data is currently bound, so once the user makes a change it is made, no submit button is required.
We are running into some difficulties in doing a dlookup from the value entered and comparing to a column in the table.
TABLE - UPDATED HEADCOUNT
COLUMN in UPDATED HEADCOUNT - EMPID
FORM CELL user will input an EMPID - newEMPID
FORM CELL used for a dlookup to compare what user has entered to what is already in the table - duplicateEMPID
So below is what we are trying to do, we are sure there are a few commands missing....
=IIF(newEMPID=dlookup([UPDATED HEADCOUNT]![EMPID]), newEMPID, "Error, EMPID already exists")
View 11 Replies
View Related
Apr 12, 2005
It should be exceedingly simple, but I got mashed potatoes between the ears today.
I make a query looking up for Name+Firstname+Ref number which I display in a tabular form .
Now, I want to use check boxes to select the ones I wants to print. But the thing is, if I add a check box in the main part of the form, it'll be the same box for all records. Not what I want.
So, how to create (add) a column so I can check individual records in the form?.
Thanks
View 2 Replies
View Related
Sep 4, 2006
Hi guys, a company in my city is giving out prizes, and for each buy you get a sheet with 25 numbers ( kind of bingo thing). Well I have like 300 sheets . So i did an Access where I enter the SheetID and the 25 numbers. Now I have to do another table where I can insert the number that will be draw and whenever one of the sheet is complete, it let me know that I win!!! and the SheetID.
Any ideas!!! please please
View 1 Replies
View Related
May 13, 2005
Hi,
i want to set values (=numbers) in fields of a table by selecting check-boxes in a form (based on the same table).
as checkbox1 =1
checkbox2= 2
etc
If the box is checked the value should be entered, if unchecked the value should be removed.
Afterwards i want to show the sum of these values in another field in the same form.
I suppose this requires VBA. Could anybody help me plz ?
Thx
View 3 Replies
View Related
Jan 17, 2006
I've had a search in the threaqds for an answer but cannot find anything specific, plus this one has stumped me.
What I need to do is check if a certain field has a value if another field has a specific value ??!!?
Ok so if Combo Box 1 is set to 1, then Combo box 2 must have a value selected.
If ComboBox 1 is set to 2, then Combo Box 3 must have a value.
for any other value for ComboBox 1 box 2 & 3 do not require a value.
If either of these statements are not correct then a message box should come up
Any help would be greatly appreciated
MattP
View 5 Replies
View Related
May 31, 2006
I have a form where I enter student names, and it often happends that I enter the same student a couple times, Is there any way to let the user know that there is allready someone in the system with the same name, like a pop up message.:confused:
thx
View 7 Replies
View Related
Aug 24, 2007
hello all,
I have no idea how to run error checking
I get this error
can't append all the records in the append query.
i want a custom error to come up instead of that.
PLEASE HELP.
View 1 Replies
View Related
Jan 5, 2006
Hi all, hope you can help me:
Basically what im trying to do is a database which checks to see if something is available.
The database is a booking system for services. I need the database to check a "booking" table to see if there is a booking on a specific date. If there is, then you cannot make a booking. If there isn't then you can.
In my "booking table" there is a list of dates of bookings. Each booking lasts a week. So if someone wants to make a booking, it cant just check to see if the first day is available, it needs to check for 6 additional days. (i.e. a booking on 01 Jan 2006). If someone wants to make a booking, the database needs to account for a whole week, so the next available booking would be on 07 Jan 2006).
How can this be done in the simplist way?
Thanks all.
View 1 Replies
View Related
Dec 12, 2005
I'm running the following line:
dbs.Execute ("DROP TABLE [tbl_No Certs]")
the problem is that sometimes the table doesn't exist... Instead of trapping the error code, is there a way I can check to see if the table exists? If it doesn't I'll simply skip this step of my code and move on.
Thanks!
View 2 Replies
View Related
Dec 13, 2005
I have tried the attached code from a previous post http://www.access-programmers.co.uk/forums/showthread.php?t=98727&highlight=table+exists but some of the code doesn't work on Microsoft Access Project.
Does anyone have any ideas how I would amend this code so that it works?
Regards
Carly
View 2 Replies
View Related
Sep 27, 2005
Hi all,
I had a little problem with delete query. I would like to delete the records by checking two fields if both fields are empty. I mean if a records had both these fields are empty only. If one of the field has data , the record should stay there.. Is there any way I can do this?
Thanks in advance.
Thanks
View 4 Replies
View Related
Jan 25, 2005
I would have thought this was easy, but I keep getting an error.
I have a form with a save button. When the save button is clicked, I want it to check if user has attached an OLE object to a bound object frame. If they have, I'd like a checkbox to be true.
Here's the code I tried:
If Attachment.LpOleObject = 0 Then
Attach.Value = False
Else
Attach.Value = True
End If
This seems so incredibly straight forward and it does work if there is an attachment. If there isn't I get the message that my database can't retrieve the value of this property.
Any help would be greatly appreciated.
View 4 Replies
View Related
Apr 5, 2005
Hi, I'm trying to do up a database for a furniture company.
I used Northwinds as a guide and made a similar Orders form.
However, I need another functionality which Northwinds do not seem to have. I want to check whether the currect Order would cause the customer to exceed his credit limit.
WHAT I DID
For this, I made a query to find the amount any single customer owes to date and the amount that he can still borrow(creditlimit-amountowed+amountpaid). I then made a button which launchs this query.
PROBLEM
The problem is I want when i click this button, the query prompts me for CustomerID, which i have to key in again. Then, it launchs the datasheet showing me the credit he would have remaining if this order went through.
It would be better if I do not need to key in his ID again, since it is already on the form when i keyed in the Order.
Further, it would be much better if I could get the button to display APPROVED/REJECT(postive/negative balance) and also display the amount of the remaining credit.
Sorry for the long description. Thanks for reading and please let me know if I missed out any crucial details.
View 2 Replies
View Related