ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access database and LabView 7.0

I want my labview program to find out the number of the last record in a MS Access database before I write new data to it.
Is this possible with LabView 7.0?

Thank you.

Tor Arne
0 Kudos
Message 1 of 5
(3,296 Views)
yes, I would use an sql query with the 'MAX' property on a counter field.
example: SELECT Max(counterfield) FROM myTable
0 Kudos
Message 2 of 5
(3,296 Views)
My method would also make use of SQL -- using the count function on a key field:

select count(fieldname) from mytable

This will return the total number of records in the table. I believe Access (through SQL) refers to the first record as record 0 (zero). You would want to double check that. If so, then the returned value would be the next record to add.

Happy wiring!
0 Kudos
Message 3 of 5
(3,296 Views)
I think you need to be careful with this method. What if some of your records were deleted previously. The "count" function will not match the value in an autonumber field.
0 Kudos
Message 4 of 5
(3,296 Views)
Tor Arne wrote in message news:<50650000000800000033D30000-1079395200000@exchange.ni.com>...
> I want my labview program to find out the number of the last record in
> a MS Access database before I write new data to it.
> Is this possible with LabView 7.0?
>
> Thank you.
>
> Tor Arne

And don't forget that you can always use an Autoincrement type for
your primary key. It auto-generates the next id for you.

http://www.aspfaq.com/show.asp?id=2174

Jeff
0 Kudos
Message 5 of 5
(3,296 Views)