Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto change x number of found records from database at the same time 2

Status
Not open for further replies.

Nikosis

Programmer
Aug 30, 2010
16
US
Hello

Lets say I want to print a list of friends addresses filtered by a city. So out of 100 records I've found "n" records of people living in a given city. It prints out just fine, but after that I have to go and mark checkbox as "printed" for each one of these records manually,
Is there a way to mark them all as "printed" by the time I hit print button.

Thx
Andy
 
What database are you using? Also, what components are you using?


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Since you are filtering records from a Database, I am going to assume you are doing so using SQL queries. You can create an update query to update all the records you have filtered, and run the query immmediately after printing, or even as a part of the printing process. The following SQL code can be used to conduct an update similar to what you want

Code:
UPDATE Friends SET Printed = true 
WHERE City IS "SomeCity"
 
Yes, I'm using .mdb ADO SQL queries.
I'm gonna try that right now.

Thx
Andy
 
Try:
Code:
UPDATE Friends SET Printed = true
WHERE City IS 'SomeCity'

(Replace the double quotations " " " with single quotations " ' ")


I was wondering whether the Access SQL engine supports the 'IS' keyword. Obviously the Access SQL engine does indeed support the 'IS' keyword. To determine that, I came across the following website:



Steve.
 
So far I can't get it to work, problem is that I search in 3 different fields, so it is difficult to determine what is used as a parameter to search in the database, on top of it, my search button opens up another window with preview and all kinds of format verifications, zooms, etc..., so from there I can actually print the page. I will try again, to make it work, but out of curiosity is there any other way to do it, lets say with record count and from there go from one row to the next one ?

Thx
Andy
 
Can you show us the SQL statement you use to select/filter on?


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
These are my statements
Code:
SELECT * FROM Event WHERE StatusComplete='F' AND LastNameID LIKE :param ORDER BY StartDate ASC
SELECT * FROM Event WHERE StatusComplete='F' AND CityID LIKE :param ORDER BY StartDate ASC
SELECT * FROM Event WHERE StatusComplete='F' AND StateID LIKE :param ORDER BY StartDate ASC
 
You show three SQL statements, which puzzles me. Does your program react to the data from each query individually one at a time?


Assuming you need to UPDATE the database *when* StatusComplete='F' AND LastNameID LIKE :param AND CityID LIKE :param AND StateID LIKE :param then the following is basically how your UPDATE query needs to read:
Code:
UPDATE Event

SET StatusComplete = 'T'

WHERE StatusComplete='F' AND
LastNameID LIKE :param AND
CityID LIKE :param AND
StateID LIKE :param


By the way, are you *really* wanting to update the database? Or are you wanting to simply update something on the main form? For example, say you have your list of friends in a TCheckListBox and you have a TButton assigned to send to a printer the data associated with each friend one at a time. Perhaps you are wanting checks to appear to the left of each friend's name as the friend's data is printed. Is this what you are wanting to do?

Steve.
 
Yes it does.
I'm not looking in 3 diff fields at the same time, it's a radiobutton choice. After I hit print it opens up another window with previews, for the last check, and from that point button "ok" prints the page, and updates database hopefully, but radiobuttons are not there so I can't use "if", how can I determine what sql command was used, in order to update only these fields that are printed out.
 
As long as the form is still open, you can still access the controls on it by way of: Application.Forms("FormName").Controls("ControlName"). If you close it out during opening of the Preview window, then don't until after you have updated the DB. If you are printing from a report or form, you can use the Record Source property to get the the SQL statement if you used a direct query, or the Query Name if you used a Saved query. If you used a saved Query, you then use CurrentDB.QueryDefs("QueryName").SQL to get the SQL statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top