Hi all
Can anyone help me with this code. I am having a form using a query to list my coustomer to be sent email who should be on time for apointment.
In Access 2000 I used While-Wend and it worked but in access 2007 it didn´t work so I change to Do While - Loop
Here is the code in Access 2000:
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
DoCmd.GoToRecord , , acFirst
While (Not (rst.EOF))
If IsNull(Me.FRTE) And Not IsNull(Me.txtEmail) Then
Dim strStDocName As String
strStDocName = "FBolusetning"
DoCmd.SendObject acReport, strStDocName, acFormatRTF, txtEmail, , , "Minnum á bólusetningu, sjá viðhengi", "Skilaboð frá " & " " & DLookup("Stofa", "Notandi"), False
End If
rst.MoveNext
If Not rst.EOF Then
DoCmd.GoToRecord , , acNext
End If
Wend
So I tryed to change it in Access 2007 to:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = Me.RecordsetClone
rst.MoveFirst
DoCmd.GoToRecord , , acFirst
Do While Not rst.EOF
If IsNull(Me.FRTE) And Not IsNull(Me.txtEmail) Then
Dim strStDocName As String
strStDocName = "FBolusetning"
DoCmd.SendObject acReport, strStDocName, acFormatRTF, txtEmail, , , "Minnum á bólusetningu, sjá viðhengi", "Skilaboð frá " & " " & DLookup("Stofa", "Notandi"), False
End If
rst.MoveNext
If (Not (rst.EOF)) Then
DoCmd.GoToRecord , , acNext
End If
Loop
If I didn´t use DoCmd.GoToRecord , , acNext then it didn´t go to next Record but now it give the error on the last record "Can´t go to the specific record"
So how can I get it to go through all my records to send without giving a notice and stoop after the last record? What am I doing wrong?
Gauja
Can anyone help me with this code. I am having a form using a query to list my coustomer to be sent email who should be on time for apointment.
In Access 2000 I used While-Wend and it worked but in access 2007 it didn´t work so I change to Do While - Loop
Here is the code in Access 2000:
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
DoCmd.GoToRecord , , acFirst
While (Not (rst.EOF))
If IsNull(Me.FRTE) And Not IsNull(Me.txtEmail) Then
Dim strStDocName As String
strStDocName = "FBolusetning"
DoCmd.SendObject acReport, strStDocName, acFormatRTF, txtEmail, , , "Minnum á bólusetningu, sjá viðhengi", "Skilaboð frá " & " " & DLookup("Stofa", "Notandi"), False
End If
rst.MoveNext
If Not rst.EOF Then
DoCmd.GoToRecord , , acNext
End If
Wend
So I tryed to change it in Access 2007 to:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = Me.RecordsetClone
rst.MoveFirst
DoCmd.GoToRecord , , acFirst
Do While Not rst.EOF
If IsNull(Me.FRTE) And Not IsNull(Me.txtEmail) Then
Dim strStDocName As String
strStDocName = "FBolusetning"
DoCmd.SendObject acReport, strStDocName, acFormatRTF, txtEmail, , , "Minnum á bólusetningu, sjá viðhengi", "Skilaboð frá " & " " & DLookup("Stofa", "Notandi"), False
End If
rst.MoveNext
If (Not (rst.EOF)) Then
DoCmd.GoToRecord , , acNext
End If
Loop
If I didn´t use DoCmd.GoToRecord , , acNext then it didn´t go to next Record but now it give the error on the last record "Can´t go to the specific record"
So how can I get it to go through all my records to send without giving a notice and stoop after the last record? What am I doing wrong?
Gauja
