PC Review


Reply
Thread Tools Rate Thread

Access 2003: Loop Through Records

 
 
eckert1961
Guest
Posts: n/a
 
      21st May 2010
Hello,

I need some assistance with the following code.

Private Sub GradeAttempting()
If Nz(Forms.Members.Ready, True) = True And Nz(Forms.Members.Active, True) =
True Then
With Forms.Members.GradeAttempting
.SetFocus
.ListIndex = .ListIndex + 1
End With
End If
End Sub

This updates a combobox, "GradeAttempting" on a main form, "Members". This
works but only for the Member page that I have the form open to. To update
the rest of the records I have to manually navigate through all members
pages and
run the code for each page.

What I want is have the code cycle through all of the records and update
GradeAttempting and I also need the checkbox, "Ready", cleared on each page.

What code do I need to add to accomplish this? Thanks.

--
Regards,
Chris
 
Reply With Quote
 
 
 
 
eckert1961
Guest
Posts: n/a
 
      21st May 2010
Hi Pieter,

Thank you for taking the time to respond. I believe that I already have what
you've outlined but I'm not sure if I'm implementing it correctly. Currently
the control source for the combobox on my Members form is a field in my
Members table, GradeAttempting. For the row source I'm using the following
query.

SELECT GradeTypes.*, GradeTypes.GradeTypeID, GradeTypes.GradeType FROM
GradeTypes ORDER BY GradeTypes.GradeTypeID, GradeTypes.GradeType DESC;

The table GradeTypes has a field, SortField, which is what you recommended.
As I noted, I'm not sure if my implementation is correct. If not, what
changes would you recommend?

Additionally, would an update query be able to select the next GradeType? If
so, how?
--
Regards,
Chris


"PieterLinden via AccessMonster.com" wrote:

> eckert1961 wrote:
> >Hello,
> >
> >I need some assistance with the following code.
> >
> >Private Sub GradeAttempting()
> >If Nz(Forms.Members.Ready, True) = True And Nz(Forms.Members.Active, True) =
> >True Then
> > With Forms.Members.GradeAttempting
> > .SetFocus
> > .ListIndex = .ListIndex + 1
> > End With
> >End If
> >End Sub
> >
> >This updates a combobox, "GradeAttempting" on a main form, "Members". This
> >works but only for the Member page that I have the form open to. To update
> >the rest of the records I have to manually navigate through all members
> >pages and
> >run the code for each page.
> >
> >What I want is have the code cycle through all of the records and update
> >GradeAttempting and I also need the checkbox, "Ready", cleared on each page.
> >
> >What code do I need to add to accomplish this? Thanks.
> >

> Using the listindex property of your combobox is a bad idea, because you
> can't run a simple update query against your table this way. You would have
> to loop through all the records in your table in code through your form and
> update each record individually. Bad plan. SQL is a set based language, so
> look for a set-based solution. put the controlsource of the combo/listbox in
> a table in order (add an indexed numeric field to your table so that the
> values your looping through essentially have a surrogate index)... e.g.
>
> Value IndexValue
> a 1
> d 2
> j 3
> e 4
>
> then you can add some constant to your IndexValue and return the right
> corresponding value in your query. (just use a join).
>
> --
> Message posted via http://www.accessmonster.com
>
> .
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converted Access 2003 database loop Marie Microsoft Access 3 22nd May 2008 09:14 PM
loop through field names, then use to loop through records topopulate grid pmacdiddie@gmail.com Microsoft Access Form Coding 1 4th Jan 2008 01:13 PM
Re: How to loop through the MS Access DB records Lucas Tam Microsoft ASP .NET 1 24th Aug 2004 12:21 AM
RE: How to loop through the MS Access DB records =?Utf-8?B?Sm9l?= Microsoft ASP .NET 0 23rd Aug 2004 10:33 PM
Re: How to loop through the MS Access DB records PL Microsoft ASP .NET 0 23rd Aug 2004 07:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 PM.