473,794 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to define a loop

Hello all,
Could anybody give me the correct syntax for defining a loop using the
form's recordset for as long as it is not at the end of the table ?

example:
Do While not EOF ' this is the part I don't know
commands ....
.....
.....
Loop

Thanks .....
Nov 12 '05
10 2117
"Ronny Sigo" <ro********@sky net.be> wrote in message
news:3f******** **************@ feed0.news.be.e asynet.net...
Hello Arnold,
I used your "more generalised DAO loop", as you suggested. I get no error
messages anymore but ...
This thing serves to automatically generate an email message with the
contents of the tabls in it ...
By each rst.Move.Next, the sBody variable is updated with the old value +
the new one, finally forming the body of the emailmessage.
By using your loop, the email msg displays the correct number of lines
(according to the numer of records in the table - 9 at present (testing)).
The weird thing is that all 9 lines are displaying the values of the first
record, so I get 9 lines exactly the same ..... this beats me .....
Here is the code .... can you see why it does that ?

Private Sub btnStuurMails_C lick()
Forms!frmBekijk Foutmeldingen.R equery
Dim nLast As Long
Dim Email As String, Subject As String, sBody As String, attach As String Dim cc As String, bcc As String

Subject = "Foutmelding(en )"
Email = "so*****@somepr ovider.be"
sBody = "Beste Karel," & vbCrLf & vbCrLf & _
"De volgende problemen werden mij gemeld. Weet jij hier een oplossing
voor?" & _
vbCrLf & "Met vriendelijke groeten," & vbCrLf & vbCrLf & _
"Steven Leman," & vbCrLf & _
"consulent ICT" & vbCrLf & vbCrLf
'DoCmd.GoToReco rd , , acFirst
tellerke = 0
Dim ronnylogic As Boolean
ronnylogic = False

' Here comes Fletcher's part ...

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblFoutmeldinge n"

Set dbs = CurrentDb

Set rst = dbs.OpenRecords et(strSQL)

Do While Not rst.EOF
If [Karel] = True Then
sBody = sBody & "Apparaat: " & Trim([Apparaat]) & "
Beschrijving: " & Trim([Beschrijving]) & _
" Datum: " & [DatumMelding] & " Gebruiker: " &
Trim([Gebruiker]) & vbCrLf & _
Trim([Gebruiker]) & " probeerde dit te herstellen met volgende
handeling(en): " & Trim([OndernomenActie]) & vbCrLf & vbCrLf
[DatumMailKarel] = Date
End If
If [Ronny] = True Then
ronnylogic = True
End If
rst.MoveNext
Loop

If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If

If Not dbs Is Nothing Then
Set dbs = Nothing
End If

' Start Outlook.
' If it is already running, you'll use the same instance...
Dim olApp As Object
'Dim olApp As Outlook.Applica tion
Set olApp = CreateObject("O utlook.Applicat ion")

' Logon. Doesn't hurt if you are already running and logged on...
Dim olNs As Outlook.NameSpa ce
Set olNs = olApp.GetNamesp ace("MAPI")
olNs.Logon

'sFunctie = DLookup("[Functie]", "tblMwerker s", "[Volledigenaam] = '" &
sNaamschrijver & "'")
' Send a message to your new contact.
Dim olMail As Outlook.MailIte m
Set olMail = olApp.CreateIte m(olMailItem)
' Fill out & send message...
'olMail.To = olItem.Email1Ad dress
olMail.To = "so*****@somepr ovider.be"
olMail.Subject = "Foutmelding(en )"
olMail.body = sBody

olMail.Display

'olMail.Send

' Clean up...
Set olNs = Nothing
Set olMail = Nothing
Set olAppt = Nothing
Set olItem = Nothing
Set olApp = Nothing
End Sub


Ronny
Your post has only just appeared on my news server - I don't know why it was
so late. Perhaps you have solved this problem by now, but if not, you could
look at setting a breakpoint at the beginning of the code and use F8 to
step through line by line and see what is going on. You could also help
yourself by reducing the code to a simpler form to make de-bugging easier.
For example, try this version:

While Not rst.EOF
str = str & Nz(rst!Beschrij ving, "") & vbCrLf
rst.MoveNext
Wend

Msgbox str

Does that work? If so, slowly build up to your code. Possible problems:

If [Karel] = True Then ... check this out

[DatumMailKarel] = Date ... this looks like you are trying to edit the
recordset. You can't do that without writing rst.Edit beforehand.
PS My first name is Fletcher

Fletcher

Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
4700
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split (PHONE_LIST, "_+")) { Console.WriteLine (phoneNumber); } } Output: 495.1000
8
1869
by: John Bailo | last post by:
What is /automatic/ garbage collection, and how do I know that it is really efficient? If I use mono, I can look at the code. But if I use Java and .NET -- I have no idea. A brilliant programmer called Jeff Relf just discovered a more efficient way of clearing memory -- does GC do this?
14
4463
by: Carl Ribbegaardh | last post by:
What other c++ constructs can I use instead of #define for executing a couple of functions? Example: #define DO_STUFF doThis(); doThat(); I'd guess that I can either use a template function, an inlined function or an inlined static method. //1
1
1239
by: jitendar.rawat | last post by:
Hi, I am trying to create a library and want its user to define a function in their executable if that library is linked. some thing like, if some uses my library and haven't defined a function like void Initialize( long a, long b) { } at link time I should get an error like "unresolved symbols" I am able to get it done if I create a dummy fnction in header file of
13
7705
by: Vinu | last post by:
The following code doesn't prints anything why it is? The code is correct. plz explain the logic #include <stdio.h> int arr = {10,20,30,40,50}; #define ARR_SIZE sizeof(arr)/sizeof(arr) void main()
5
11442
by: Stuart Norris | last post by:
Dear Readers, I am attempting to define an array of IPAddress-es in C#. I wish to have a array of address so I can try in order to connect to them in a loop to handle unavailable hosts. Todate since I do not know how to define an array of IPAddress-es. I have been defining variable like:
17
3087
by: David Isaac | last post by:
I would like to be able to define a loop statement (nevermind why) so that I can write something like loop 10: do_something instead of for i in range(10): do_something
7
339
by: anjna22 | last post by:
#define prvCheckDelayedTasks() { register tskTCB *pxTCB; while((pxTCB = (tskTCB *) listGET_OWNER_OF_HEAD_ENTRY(pxDelayedTaskList)) != NULL) { if(xTickCount < listGET_LIST_ITEM_VALUE( & (pxTCB- } }
23
3923
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.