Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2004, 10:19 PM
Authorized User
 
Join Date: Nov 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default code to search a record


Hello Guys,

Can you give me a code to search a data from the table. I want to validate the entry(PRODUCT CODE) to see if already exist in the table or not. The simplest code to search a record.

rsproduct is my recordset.
prdcode is on of my fields to search on.

Rudner

 
Old November 17th, 2004, 11:52 PM
Aal Aal is offline
Authorized User
 
Join Date: Oct 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello Rudner . . .
try this code :
----------------------------------------------------
Function Existence(Byval iNdx$,Byval iData$) as Boolean

      rc.Open "SELECT [" & INdx & "] FROM PRODUCTS WHERE [" & iNDX & "]='" & IData & "'"
      if Not Rc.EOF then
         Existence = True
      end if

End Function
-----------------------------------------------------
To Use it :
    If Existence("YOUR PRIMARY FIELD","VALUES FROM CONTROLS") then
       msgbox "DUPLICATE DATA",,"ZERO ICE"
       exit sub
    end if
-----------------------------------------------------
that's all. And if you put new parameter as Recordset you'll be able to check all primary in a table just with this function.
bye . . . and happy coding !!!!!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and match record from two tabel delion Pro VB Databases 1 May 15th, 2007 11:51 AM
Search for a record using a form a_wahab Access 6 September 1st, 2006 12:03 PM
How do you open a specific record from a search? Szimmer9 VB How-To 1 March 31st, 2006 12:57 AM
search for duplicates before storing new record phytcmg Access VBA 3 April 1st, 2005 11:30 AM
How to search for (and select) a record? Haroldd Access 2 June 30th, 2003 06:50 PM





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