Hi Leute,
ich hab wieder mal ein CodeProblem. Dieser Code macht folgendes. Das erste überprüft das Excelsheet um herauszufinden auf welcher Datenbank die Daten vom Excelsheet in die DB einzulesen sind.
Wenn nun das Programm die Stelle mit rsPM.AddNew erreicht, bricht es genau dort ab und bringt mir diese Fehlermeldung: Laufzeitfehler '91' Objektvariable oder With-Blockvariable nicht festgelegt.
Wisst ihr wo der Fehler liegt?
Ich hab mir gedacht, dass es vielleicht hilft, wenn ich um rsPM.AddNew und rsPM.Update ein weitere If bastle, welche auf rsPM.RecordCount = 1 abfrägt; hat aber auch nichts geholfen; leider.
Danke!
Edit by Dodo:
-> Topic verschoben (Gundlagen => VBA)
ich hab wieder mal ein CodeProblem. Dieser Code macht folgendes. Das erste überprüft das Excelsheet um herauszufinden auf welcher Datenbank die Daten vom Excelsheet in die DB einzulesen sind.
Visual Basic-Quellcode
- If Not ((xwsin.Cells(rowin, 2) = "") And (xwsin.Cells(rowin, 3) = "") _
- And (xwsin.Cells(rowin, 9) = Trim(xwsin.Cells(rowin, 9)))) Then
- 'Zweig für PM-Tabelle
- rsPM.AddNew
- If Cells(rowin, 1) = "1" Then rsPM!ProjectManager = xwsin.Cells(rowin - 1, 1)
- If Cells(rowin, 2) = "1" Then rsPM!ProjectID = xwsin.Cells(rowin - 1, 2)
- If Cells(rowin, 3) = "1" Then rsPM!ProjectDescription = xwsin.Cells(rowin - 1, 3)
- If Cells(rowin, 4) = "1" Then rsPM!Type = xwsin.Cells(rowin - 1, 4)
- If Cells(rowin, 5) = "1" Then rsPM!ProductLine = xwsin.Cells(rowin - 1, 5)
- If Cells(rowin, 6) = "1" Then rsPM!SystemProject = xwsin.Cells(rowin - 1, 6)
- If Cells(rowin, 7) = "1" Then rsPM!SystemTxt = xwsin.Cells(rowin - 1, 7)
- If Cells(rowin, 8) = "1" Then rsPM!Location = xwsin.Cells(rowin - 1, 8)
- If Cells(rowin, 9) = "1" Then rsPM!EndDate = xwsin.Cells(rowin - 1, 9)
- If Cells(rowin, 10) = "1" Then rsPM!June2012 = xwsin.Cells(rowin - 1, 10)
- If Cells(rowin, 11) = "1" Then rsPM!July2012 = xwsin.Cells(rowin - 1, 11)
- If Cells(rowin, 12) = "1" Then rsPM!August2012 = xwsin.Cells(rowin - 1, 12)
- If Cells(rowin, 13) = "1" Then rsPM!September2012 = xwsin.Cells(rowin - 1, 13)
- If Cells(rowin, 14) = "1" Then rsPM!October2012 = xwsin.Cells(rowin - 1, 14)
- If Cells(rowin, 15) = "1" Then rsPM!November2012 = xwsin.Cells(rowin - 1, 15)
- If Cells(rowin, 16) = "1" Then rsPM!December2012 = xwsin.Cells(rowin - 1, 16)
- If Cells(rowin, 17) = "1" Then rsPM!January2013 = xwsin.Cells(rowin - 1, 17)
- If Cells(rowin, 18) = "1" Then rsPM!February2013 = xwsin.Cells(rowin - 1, 18)
- If Cells(rowin, 19) = "1" Then rsPM!March2012 = xwsin.Cells(rowin - 1, 19)
- If Cells(rowin, 20) = "1" Then rsPM!April2013 = xwsin.Cells(rowin - 1, 20)
- If Cells(rowin, 21) = "1" Then rsPM!May2013 = xwsin.Cells(rowin - 1, 21)
- If Cells(rowin, 22) = "1" Then rsPM!June2013 = xwsin.Cells(rowin - 1, 22)
- If Cells(rowin, 23) = "1" Then rsPM!PREMail = xwsin.Cells(rowin - 1, 23)
- rsPM.Update
- End If
- Else
Wenn nun das Programm die Stelle mit rsPM.AddNew erreicht, bricht es genau dort ab und bringt mir diese Fehlermeldung: Laufzeitfehler '91' Objektvariable oder With-Blockvariable nicht festgelegt.
Wisst ihr wo der Fehler liegt?
Ich hab mir gedacht, dass es vielleicht hilft, wenn ich um rsPM.AddNew und rsPM.Update ein weitere If bastle, welche auf rsPM.RecordCount = 1 abfrägt; hat aber auch nichts geholfen; leider.
Danke!
Edit by Dodo:
-> Topic verschoben (Gundlagen => VBA)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Dodo“ ()