View Single Post
 
Old March 9th, 2005, 12:52 PM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   A simple way to do this (assuming you are properly accessing the database) is to do something like the following:

'==========
Set cnn = Connection
Set rs = Recordset
'...
stName = "John Doe"
stSQL = "SELECT * FROM tblYourTable WHERE Name = " & stName
rs.Open stSQL, cnn, 3, 3
   If rs.RecordCount = 1 Then
      With rs
      intNameID = rs.Fields(0) 'this is usually the PK field #
      End With
   End If
rs.Close
cnn.Close
'...
'==========

   You really have to make sure that your Names are unique, which is very difficult, unless you are dealing with a small group of people.

HTH

mmcdonal