RSView Access VBA/SQL question

TConnolly

Lifetime Supporting Member
Join Date
Apr 2005
Location
Salt Lake City
Posts
6,152
I'm using RSView VBA to record the last parameter adjustments made for a given product in an MS Access data base. The Access table contains PartNumber (string), Param1, Param2, Param3,(integers), and LastUsed (Date/Time) fields.

Reading and Updating existing records is easy. However, UPDATE only works if the part number is already in the data base. Whenever a new part number is created its necessary for someone to add it to the DB. I want any new part number to automatically add to the data base table, but to do that apparently I have to use the APPEND statement.

Is there a different SQL statement that will update the values if the record exists, or automatically append if the record doesn't exist? Or do I need to first query to see if the record exists and then choose whether to use UPDATE or APPEND? If so, how do I query to see if the record exists?
 
To query if it does not exist - query if it exists and expect an error code or similar. What does UPDATE give as return code on a non existing record?
 
I've got something that works...

First I run a SELECT query on PartName, then check to see if a record was found.

rsParaRecordSet = dbParaDataBase.OpenRecordset("SELECT PartName FROM Parameters Where PartName = " & SPN & ";")

If rsParaRecordSet.EOF Then
The record doesn't exist, add one using INSERT IGNORE INTO SQL statement
ELSE
The record exists, update it using UPDADE SQL statement.

What I don't like about it is it requires two queries to the Database.

Surely there has got to be a better way.
 
Ach... after writing all that, I remembered you were using Access (yech).

Normally, I'd just write a stored procedure for the insert/update and let it decide what to do, but I don't think Access supports stored procedures.

For the record as well, Microsoft's SQL Server Express is still available free for development and production.
 

Similar Topics

First let me post the reason. I need to have RSView interact with an external application tying the alarms to an external logging application...
Replies
11
Views
11,374
Hi All, I am trying to setup a new data log model in RSview 32 with storage as ODBC and assigning the microsoft access driver. I created a new...
Replies
5
Views
4,099
Hi friends I have a change of integrating RSView32 HMI to read value from MS office access database. HMI running on RS link OEM Asst which is the...
Replies
0
Views
1,748
Is there a way to configure an Ethernet I/P direct driver in RSView 32 to "drill-down" thru a 1756-ENBT to a 1756-DHRIO and access a 5/04 CPU on...
Replies
7
Views
5,495
Hello fellow wirenuts, I am looking to find the P.B. touch indicator option on version 13.00 and failing. It has been a year or so since I last...
Replies
9
Views
269
Back
Top Bottom