check double records in database

T

tinybears

Hey,

I'm looking for a code to know if a row with primarty key ticker is
already in my table DDM.
I use the following code but there seem som problems. It says the
variable TextTicker.Text is not defined. Can someone help me out? Thx

s_Path = ActiveWorkbook.Path
s_Path = s_Path & "\Thesis.mdb"

Set DB = DAO.OpenDatabase(s_Path)

s_SQL = "SELECT Ticker & FROM DDM " _
& "WHERE Ticker = ' & Me.TextTicker & " ';"


If s_SQL = TextTicker.Text Then

MsgBox "Found"

Else

MsgBox "Not found"
GoTo execute_code:


End If

Set rs = Nothing
Set DB = Nothing

execute_code:
 
P

Puppet_Sock

tinybears said:
I'm looking for a code to know if a row with primarty key ticker is
already in my table DDM.
I use the following code but there seem som problems. It says the
variable TextTicker.Text is not defined. Can someone help me out? Thx

s_Path = ActiveWorkbook.Path
s_Path = s_Path & "\Thesis.mdb"

Set DB = DAO.OpenDatabase(s_Path)

s_SQL = "SELECT Ticker & FROM DDM " _
& "WHERE Ticker = ' & Me.TextTicker & " ';"


If s_SQL = TextTicker.Text Then

MsgBox "Found"

Else

MsgBox "Not found"
GoTo execute_code:


End If

Set rs = Nothing
Set DB = Nothing

execute_code:

Ok, I'm looking, and I don't see anywhere that TextTicker is defined,
except possibly as part of "Me" which itself is not defined. So, what
if you put Me.TextTicker instead of TextTicker? Is Me defined?

Also, the line
If s_SQL = TextTicker.Text Then

looks pretty weird. It looks like s_SQL is supposed to be a SQL
command, so presumably there's a database around someplace.
Why do you expect TextTicker.Text to be equal to this command?

The rest looks pretty weird also. If the equality is true, then you
set rs and DB to Nothing. But if it is not true, you don't. What's up
with that? And what is rs?

Also, if it is a SQL command, are you planning to execute it?

I think you need a book to read about this stuff. You seem to have
plenty of problems.
Socks
 
T

tinybears

That's why I'm freaking out about it. I need to hand it in next week. O
well ...

thx for your honest reply
 
Top