K
kentexcel
Hi
I amtrying to Update a table with fields Year=1 and field Month shall update
with 1 to 12.
My code looks like this but it don´t work .
*********************************************************
Private Sub cmdNyttÃ…r_Click()
'********************************************************************************
Dim rst As ADODB.Recordset
Dim rstUppdatera As ADODB.Recordset
Dim strMessage As String
Dim strSQL As String, intÃ…rsID As Integer
Dim x As Variant, i As Integer
Set rst = New ADODB.Recordset
Set rstUppdatera = New ADODB.Recordset
' On Error GoTo Felhanteraren
'Skapa SQLuttryck för recordset
strSQL = "SELECT * FROM tblmedlem"
rstUppdatera.Open strSQL, CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic
rst.Open "tblBetalningar", CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic, adCmdTableDirect
intÅrsID = InputBox("Ange årsID. Årsid är årtal +1. Ex: År 2009 har
Ã¥rsid 10")
'Loopa igenom hela postuppsättningen
Do While Not rstUppdatera.EOF
With rst
.AddNew
.Fields("MedlemsID") = rstUppdatera.Fields("MedlemsID").Value
.Fields("Ã…rsID") = intÃ…rsID
For i = 1 To 12
.Fields("MÃ¥nadsID") = i
rstUppdatera.MoveNext
Next
rstUppdatera.MoveNext
End With
'Uppdatera
Loop
'rst.Close
Set rst = Nothing
End
Felhanteraren:
MsgBox "Ett fel uppstod", vbInformation
End Sub
Thanks for any helpor guidance
I amtrying to Update a table with fields Year=1 and field Month shall update
with 1 to 12.
My code looks like this but it don´t work .
*********************************************************
Private Sub cmdNyttÃ…r_Click()
'********************************************************************************
Dim rst As ADODB.Recordset
Dim rstUppdatera As ADODB.Recordset
Dim strMessage As String
Dim strSQL As String, intÃ…rsID As Integer
Dim x As Variant, i As Integer
Set rst = New ADODB.Recordset
Set rstUppdatera = New ADODB.Recordset
' On Error GoTo Felhanteraren
'Skapa SQLuttryck för recordset
strSQL = "SELECT * FROM tblmedlem"
rstUppdatera.Open strSQL, CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic
rst.Open "tblBetalningar", CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic, adCmdTableDirect
intÅrsID = InputBox("Ange årsID. Årsid är årtal +1. Ex: År 2009 har
Ã¥rsid 10")
'Loopa igenom hela postuppsättningen
Do While Not rstUppdatera.EOF
With rst
.AddNew
.Fields("MedlemsID") = rstUppdatera.Fields("MedlemsID").Value
.Fields("Ã…rsID") = intÃ…rsID
For i = 1 To 12
.Fields("MÃ¥nadsID") = i
rstUppdatera.MoveNext
Next
rstUppdatera.MoveNext
End With
'Uppdatera
Loop
'rst.Close
Set rst = Nothing
End
Felhanteraren:
MsgBox "Ett fel uppstod", vbInformation
End Sub
Thanks for any helpor guidance