Working in VB: How to create this Access query ?

F

Faraz Azhar

Hello

I have a VB project and a database in MS Access. Im trying to create a
query for my project but Im unable to figure it out. I'll explain a
summary of my project here:

I have a table called Employees. In this table there are two fields,
EmployeeID (autonumber + primary key) and EmployeeName (text).

Im trying to accomplish is that I run an SQL statement which returns
me the ID of any given employee name and if that name DOESNT exist,
then the sql should create an entry and then return its ID.

For searching a record I use this (using the Recordset object):
RS.Open "SELECT * FROM [Employees] WHERE EmployeeName='" & szName &
''"

This runs ok. For adding a record I run this query (using the
Connection object):
Conn.Execute "INSERT INTO Employees (EmployeeName) VALUES (""" &
szName & """);"

Now my problem is how can I combine the above two into a single sql
statement ? Foremost; is it even possible ?

Im trying to combine because I have only stated a small proportion of
my project. It will be running on large scale and on different types
of data, so I want the query to run only once to avoid excessive
coding and reduce processing time.

Can anyone help?
 
S

Stefan Hoffmann

hi,

Faraz said:
Now my problem is how can I combine the above two into a single sql
statement ? Foremost; is it even possible ?
No, it is not possible.


mfG
--> stefan <--
 

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