Hoe kan ik na het invoegen van een record in access vanuit visual basic het autoincrement veld opvragen? Ik wil dus hetzelfde als je in PHP kunt bereiken met "mysql_insert_id()".
Google vind ik een paar resultaten, maar geen oplossing. Op dit forum en andere staat hier ook niets over.
Google vind ik een paar resultaten, maar geen oplossing. Op dit forum en andere staat hier ook niets over.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| Public cnUniversal As ADODB.Connection
Public Function OpenConnection()
Set cnUniversal = New ADODB.Connection
With cnUniversal
If .State <> adStateOpen Then
.ConnectionString = "c:\mijn documenten\projecten\factuur\db\factuur.mdb" '
.CursorLocation = adUseClient
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open
End If
End With
End Function
Public Function ExecuteSQL(strSQL As String) As ADODB.Recordset
Dim rsUniversal As ADODB.Recordset
Set rsUniversal = New ADODB.Recordset
With rsUniversal
.ActiveConnection = cnUniversal
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Source = strSQL
.Open
End With
Set ExecuteSQL = rsUniversal
End Function
Private Sub Invoegen()
OpenConnection
Dim rsBestel As ADODB.Recordset
Set rsBestel = ExecuteSQL("INSERT INTO bestel (bestel_datum) VALUES('22/10/2003')")
End Sub |
[ Voor 9% gewijzigd door Fles op 22-10-2003 16:08 ]