Hvorfor må jeg ikke lave en movelast VB siger: "Object Variable or with block variable not set" ------------------------------------------------------- Private Sub Oktour_Click() Dim rs As ADODB.Recordset Dim rs2 As ADODB.Recordset Dim str As String Dim str2 As String Dim tourid As Integer
eksitour = TourCombo.Text
If eksitour = "" Then tournavn = Text1.Text distance = Int(Text2.Text)
str = "SELECT TourID FROM Tour WHERE TourID = " & tourid
sql.SQLConn Set rs = sql.rsSelect(str) funcs.tourid = rs("TourID") MsgBox funcs.tourid sql.Disconnect Form2.Enabled = False Form2.Visible = False End If
End Sub ------------------------------------------------------
min SQL klasse: ------------------------------------------------------- Option Explicit 'connection variable Dim cn As New ADODB.Connection Dim tmp As String Public Sub SQLConn() cn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\data.mdb" End Sub
Public Sub Disconnect() 'Lukker forbindelsen cn.Close End Sub
Public Function rsSelect(record As String) As ADODB.Recordset 'Bruges når man skal hente noget fra en tabel Dim rs As ADODB.Recordset
tmp = record
'initialiserer recordset Set rs = New ADODB.Recordset
'Åben recordset rs.Open tmp, cn
Set rsSelect = rs
End Function
Public Sub rsExecute(record As String) 'Bruges når man skal indsætte,update eller slette noget fra en tabel. Dim rs As ADODB.Recordset
tmp = record
'initialiserer recordset Set rs = New ADODB.Recordset
'Åben recordset rs.Open tmp, cn End Sub -----------------------------------------------------
you need to place Dim rs As ADODB.Recordset at the top of the module OUTSIDE the sub, at the moment you have THREE rs recordsets and as far as I can see this one is NOT getting set
the function rsSelect returns a records BUT it is NOT called until AFTER the error. The function rsExecute DOES NOT return a recordset, it doesnt do much at all in fact! So I suggest you take a VERY carefull look at your code and decide what it is your trying to do. Then do one thing at a time and get that working first before going onto the next step.
jeg har fået fikset en del og nu siger den at "Rowset does not support fetching backward"
ændret kode... --------------------------------------------------------------------------- Dim cn As New ADODB.Connection Private Sub Oktour_Click() Dim rs As ADODB.Recordset Dim rs2 As ADODB.Recordset
Dim str As String Dim str2 As String Dim tourid As Integer
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.