School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,003 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,971 people online right now. Registration is fast and FREE... Join Now!




Access VBA

 

Access VBA, Loop through the results returned by a query

Astano

11 Jun, 2009 - 01:09 AM
Post #1

New D.I.C Head
*

Joined: 9 Jul, 2007
Posts: 27



Thanked: 2 times
My Contributions
Hi,

I have a form in an Access database - it returns a set of results based on a query.

I have a button on the form and when I click it I want it to put todays date in a field for each of the results returned.

I know how to asign the date to the field:

Me![Checklists available].Value = Date

But this only puts it in the first record returned. I know I need to do some form of for/while loop and the research I have done already has mainly shown code for looping through all records in a table. I assume the principle is the same, however, I don't understand how to implement it for the results of a query.

Help, a prod in the right direction, or anything would be much appreciated.

Thanks,
Astano

This post has been edited by Astano: 11 Jun, 2009 - 02:38 AM

User is offlineProfile CardPM
+Quote Post


tommyflint

RE: Access VBA

11 Jun, 2009 - 11:44 AM
Post #2

D.I.C Addict
Group Icon

Joined: 24 Jul, 2008
Posts: 591



Thanked: 28 times
My Contributions
I'm may be wrong here but couldn't you just run a second query on that button click and run an update query and update that column to Now() where it equals the criteria?

tommyflint
User is offlineProfile CardPM
+Quote Post

P4L

RE: Access VBA

11 Jun, 2009 - 12:18 PM
Post #3

Geek 4 Life
Group Icon

Joined: 7 Feb, 2008
Posts: 2,178



Thanked: 16 times
Dream Kudos: 125
My Contributions
TommyFlint, you are headed in the right direction. Try this though, add a second field in the table, call it "PullDt" or whatever you want, and when you run the update query from the button. The SQL for the update is:

sql

UPDATE Table SET Table.PullDt = Date()
WHERE (((Table.PullDt) Is Null));


Then, you will have a distinct record for when each item was pulled. If you take out the "Where" clause, it will over ride whatever is in that field. This is the best way that I know of to do this operation.

Enjoy!

This post has been edited by P4L: 11 Jun, 2009 - 12:34 PM
User is online!Profile CardPM
+Quote Post

Astano

RE: Access VBA

11 Jun, 2009 - 11:37 PM
Post #4

New D.I.C Head
*

Joined: 9 Jul, 2007
Posts: 27



Thanked: 2 times
My Contributions
Thank you both, your replies helped me come to a solution, I never even thought of running an update query, I am quite new to using Access.
User is offlineProfile CardPM
+Quote Post

P4L

RE: Access VBA

12 Jun, 2009 - 04:43 AM
Post #5

Geek 4 Life
Group Icon

Joined: 7 Feb, 2008
Posts: 2,178



Thanked: 16 times
Dream Kudos: 125
My Contributions
Well, I use Access on a daily basis. If you need help, just pm me.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:36AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month