VBA and Form help (1 Viewer)

KLLRDRAGON

New member
Local time
Today, 01:22
Joined
Oct 16, 2009
Messages
2
I have a form that has a couple of check boxes on it. For each record, there is an "open" and "closed" check box. What I need to do is to search all records in the database for any record that is marked Open, and then run another script that will write to a text file. I got my code to write the text file, but I can't figure out how to loop through all the records while looking for only the records marked Open. I am using Access 2007 if that helps.
 

jardiamj

Registered User.
Local time
Today, 01:22
Joined
Apr 15, 2009
Messages
59
Can't that be done by doing a Query? I think you could do it by using a recordset. But I think I don't have the whole idea of what you are trying to acomplish to give you a precise idea.
 

Scooterbug

Registered User.
Local time
Today, 04:22
Joined
Mar 27, 2009
Messages
853
Create a query with what you want to export and set the criteria for the Open/Closed check box to Open. You can then use that as your record source for the code to export.
 

KLLRDRAGON

New member
Local time
Today, 01:22
Joined
Oct 16, 2009
Messages
2
ok, I can create a query to find all the open records, but how do i get the code to loop through those records? What I am doing is basically creating a Google Earth file, but using my Access database to dynamically build the files for me based on the open/closed criteria. Every open record needs to create the placemark, etc. The code I have to do that works just fine, but I can't get it to loop through multiple records, it only does it for one record.
 

Scooterbug

Registered User.
Local time
Today, 04:22
Joined
Mar 27, 2009
Messages
853
you have to use a loop in your code.

Code:
Dim db as dao.database
dim rs as dao.recordset
 
set db = Currentdb
set rs = db.openrecordset("YourQueryName")
 
with rs
 .movefirst
 
Do
   Do Until .EOF
      'Your code here
      .move next
   Loop 
Loop until .eof
 
end with
 
set db = nothing
set rs = nothing
 

Users who are viewing this thread

Top Bottom