Insert into just the top row

  • Thread starter mcarlyle via AccessMonster.com
  • Start date
M

mcarlyle via AccessMonster.com

I want to use this statement to insert information into just the top row of
available rows...

Dim SQL3 As String

SQL3 = "UPDATE [Unasigned new leads2] SET [Unasigned new leads2].
Salesperson = [forms]![greybar]![salesperson]"

DoCmd.RunSQL SQL3


The problem is that this will insert the information into all available rows..
. how do I just get it to go to the top one?
 
D

Damon Heron

what is unique about the "top" row? Do you mean the last record, or???
If so, you can add a where condition to your SQL stmt.

Damon
 
M

mcarlyle via AccessMonster.com

I just want to assign One record instead of all of them... the code assigns
all available records instead of just one.

top or bottom doesn't really matter... just 1.

Damon said:
what is unique about the "top" row? Do you mean the last record, or???
If so, you can add a where condition to your SQL stmt.

Damon
I want to use this statement to insert information into just the top row of
available rows...
[quoted text clipped - 9 lines]
rows..
how do I just get it to go to the top one?
 
D

Damon Heron

Still don't fully understand your table "Unasigned new leads2", but there
has to be something
unique about each record, otherwise the table is not designed correctly. If
salesperson is empty in the record, then you want to put the salesperson
from the form into the record? You could try:

SQL3 = "UPDATE [Unasigned new leads2] SET [Unasigned new leads2].
Salesperson = [forms]![greybar]![salesperson] WHERE isnull([Unasigned new
leads2].
Salesperson)"

However, if there are multiple blank entries for salesperson, then this will
not work. The control source of your form could be the table, and when you
add a salesperson in the field for salesperson, the record will be
saved, no sql needed.
Explain further what you are trying to do.
Damon


mcarlyle via AccessMonster.com said:
I just want to assign One record instead of all of them... the code assigns
all available records instead of just one.

top or bottom doesn't really matter... just 1.

Damon said:
what is unique about the "top" row? Do you mean the last record, or???
If so, you can add a where condition to your SQL stmt.

Damon
I want to use this statement to insert information into just the top row
of
available rows...
[quoted text clipped - 9 lines]
rows..
how do I just get it to go to the top one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top