Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 3rd, 2003, 12:05 PM
Registered User
Join Date: Oct 2003
Location: Cleveland, Ohio, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to echajmovic
Default Check for existing record


How do I check for an existing record in a table before attempting to enter the record. My table has 3 primary keys which are SchoolID, SchoolYearID, and TeacherID.


Reply With Quote
  #2 (permalink)  
Old November 3rd, 2003, 08:03 PM
Friend of Wrox
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

You could open a recordset, with those three fields as criteria, and make sure the record count is 0.
For example:

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset( _
   "SELECT * " _
   & "FROM tblSchool " _
   & ""WHERE ((([SchoolID])=" & Me.txtSchoolID _
   & ") AND (([SchoolYearID])=" & Me.txtSchoolYearID _
   & ") AND (([TeacherID])=" & Me.TeacherID & "));"

If rst.RecordCount > 0 Then MsgBox "Data Exists"

.....or something along those lines


I am a loud man with a very large hat. This means I am in charge
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a new record between two existing records hsncompany BOOK: Beginning Access 2003 VBA 0 April 13th, 2008 03:36 PM
Check For Existing Folders & Files zandermax Access VBA 2 September 30th, 2005 11:43 AM
How to check whether a filie is existing szms VB.NET 2002/2003 Basics 2 December 6th, 2004 03:49 PM
Want to insert a new record when an existing recor lionofthejungle Access 1 September 9th, 2004 11:55 AM
check for existing records b4 insertion deian Access ASP 11 June 13th, 2004 09:01 AM

All times are GMT -4. The time now is 09:20 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.