|
-
May 12th, 2006, 12:56 PM
#1
Thread Starter
Addicted Member
Check if Record exists in Access Table
Hello,
I'm using Access 2000 and VB6.
I need to do a search to check if a record exists in a table, if it does I then need to display a message saying so.
The record being searched for is a Number in a field named "OurRef" in a table named "RecordInUse".
Any ideas because I think I am missing the obvious sollution.
Thanks,
SKM
-
May 12th, 2006, 01:00 PM
#2
Re: Check if Record exists in Access Table
Run a query against the table to see how many records have the value you are searcing for. If the answer is zero, then the value doesn't exist.
Code:
SELECT Count(*) FROM RecordInUse WHERE OurRef = ValueToSearchFor
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
May 12th, 2006, 01:01 PM
#3
Re: Check if Record exists in Access Table
Do a SELECT OurRef FROM RecordInUse WHERE OurRef = Value_To_Look_For
Create a recordset
If the recordset is empty, it doesn't exist. If the recordset is not empty, it does.
-
May 12th, 2006, 01:02 PM
#4
Re: Check if Record exists in Access Table
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
May 12th, 2006, 10:29 PM
#5
Re: Check if Record exists in Access Table
 Originally Posted by DKenny
You say tomato, I say...
...faster.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
May 14th, 2006, 11:45 AM
#6
Thread Starter
Addicted Member
Re: Check if Record exists in Access Table
Hi,
How do I find out the value of the Recordset or if the recordset is empty.
Thanks,
SKM
-
May 15th, 2006, 02:22 AM
#7
Hyperactive Member
Re: Check if Record exists in Access Table
VB Code:
msgbox ObjRS("XYZ") 'Displays the value in the XYZ column(of current row)
The Difference between a Successful person and others is not a Lack of Knowledge,
But rather a Lack of WILL 
-
May 16th, 2006, 04:24 AM
#8
Re: Check if Record exists in Access Table
Something like...
VB Code:
Dim adoRecordset As ADODB.Recordset
Set adoRecordset = New ADODB.Recordset
With adoRecordset
.Open
If Not (.EOF And .BOF) Then
MsgBox "There is record!"
Else
MsgBox "There is no record!"
End If
.Close
End With
Set adoRecordset = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|