A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

duplicate check for multiple fields



 
 
Thread Tools Display Modes
  #1  
Old April 4th, 2005, 08:13 PM
Marvin
external usenet poster
 
Posts: n/a
Default

Correction:
This is probably not the only way to do it, but I would use a SQL statement
with a separate recordset to check for the existence of the data and use the
recordcount to determine whether to add the new record.

e.g.

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from TheTable where TheField = '"
& Me.txtName & "'")

If (rs.BOF And rs.EOF) Then ' Ensure the recordset is empty
' Insert the data (with add record or Append SQL statement)
End If
....



"Marvin" wrote:

This is probably not the only way to do it, but I would use a SQL statement
with a separate recordset to check for the existence of the data and use the
recordcount to determine whether to add the new record.

e.g.

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from TheTable where TheField = '"
& Me.txtName & "'")

If Not (rs.BOF And rs.EOF) Then
' Insert the data (with add record or Append SQL statement)
End If
...

"Dennis" wrote:

I have two fields on a form, First Name and Last Name. When the user clicks
ADD NEW, I want his data entered to be checked against existing data. If BOTH
fields match, he gets an error. Is there a clean way to do this using the

DoCmd.GoToRec,,,acNewRec

command? What would I need to use in conjunction with that command in order
to do what I want?

Thanks!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I spell check locked form fields? selzmank General Discussion 1 January 12th, 2005 05:12 PM
Relationship Help Michael General Discussion 8 October 14th, 2004 03:13 PM
Duplicate Check RUSS Worksheet Functions 4 October 1st, 2003 11:11 PM


All times are GMT +1. The time now is 02:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.