Please help with this code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I ahve this code:
Function hent()
username = ReturnUserName
Dim db As Database
Dim rs As Recordset
Dim rs2 As Recordset

Set db = CurrentDb()
'Set rs = db.OpenRecordset("undervisere")
strSQL2 = "Select * from tilmelding where behandlet = 0"
Set rs2 = db.OpenRecordset(strSQL2, dbOpenSnapshot)
Do While Not rs2.EOF
navn = rs2("navn")

adresse = rs2("adresse")
postnr = rs2("postnr")

strSQL = "SELECT * FROM kunder WHERE navn like '" & navn & "' and
adresse1 like '" & adresse & "' and postnummer like '" & postnr & "' "

Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)

If Not rs.EOF Then
Dim db3 As DAO.Database
Dim rs3 As DAO.Recordset
Set db3 = CurrentDb()
Set rs3 = db3.OpenRecordset("tilmelding")
rs3.Index = "kursusplanid"
rs3.Seek "=", rs2("kursusplanid")

rs3.Edit
rs3("kundenr") = rs("kundenummer")
rs3.Update

rs3.Close
End If
rs2.MoveNext
Loop
End Function
Its works fine when i use access alone but now i have my table on a sql
server
then i get error in :
rs3.Index = "kursusplanid"
rs3.Seek "=", rs2("kursusplanid")

What i do is look in a table after record where
behandlet = 0
then i look in another tabel to see if the same klient is in this table
are the klient in this table i want to update the first table whit a klientID
rs3.Edit
rs3("kundenr") = rs("kundenummer")
rs3.Update
hope someone can help
Alvin
 
Back
Top