philaman01
New Member
- Joined
- Mar 25, 2005
- Messages
- 6
Hello All...
I need to write some logic so that the database will write new records in succession after each instance.
For example, a user enters 5 records into a spreadsheet and they are saved in the DB as record 1300-1304 respectively. In the next instance, another user adds 5 more records so the DB should write records starting at the next available record (1305). Below you will find my code. Prompt response appreciated. Thanks!
On Error Resume Next
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source=\\xxxxxxx\documents\xxxxxx\My Documents\Sandbox\Event Management.mdb"
.CursorLocation = adUseClient
.Mode = adModeReadWrite
.Open
End With
rs.Open "Passwords", cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
Dim intCounter As Integer
Dim intMax As Integer
intMax = 5
intCounter = 0
Do While intCounter < intMax
rs.Fields("Used") = True
Debug.Print rs!recordid & " " & rs!Password & " " & rs!Used
intCounter = intCounter + 1
rs.MoveNext
Loop
I need to write some logic so that the database will write new records in succession after each instance.
For example, a user enters 5 records into a spreadsheet and they are saved in the DB as record 1300-1304 respectively. In the next instance, another user adds 5 more records so the DB should write records starting at the next available record (1305). Below you will find my code. Prompt response appreciated. Thanks!
On Error Resume Next
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source=\\xxxxxxx\documents\xxxxxx\My Documents\Sandbox\Event Management.mdb"
.CursorLocation = adUseClient
.Mode = adModeReadWrite
.Open
End With
rs.Open "Passwords", cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
Dim intCounter As Integer
Dim intMax As Integer
intMax = 5
intCounter = 0
Do While intCounter < intMax
rs.Fields("Used") = True
Debug.Print rs!recordid & " " & rs!Password & " " & rs!Used
intCounter = intCounter + 1
rs.MoveNext
Loop