Looping (1 Viewer)

Elise_L

Registered User.
Local time
Today, 21:30
Joined
Jul 19, 2000
Messages
13
I can get my looping to work!!

What I want is to be able to load a form up with several checkboxes. According to the ID that has been chosen, the appropriate check boxes should either be selected or deselected. I'm pretty sure a loop is needed, I've got it working soi that the first record is chosen, but I think I need to look round several times to get the other records selected, don't I?

I get error messages when I use .EOF

I've posted a similar question before, but with no response, I'm really stuck, and totally new to Access and VB scripting, I'm picking it up as I go along, so any tips will be much appreciated.

THANK YOU!!! Elise

BTW: just so you can see my thinking (what thinking!) the code goes something like this so far:

Do until .EOF
If Material = "composites" Then
ChkComposites = True
End If
If Material = "metal" Then
ChkMetal = True
End If
etc.
Loop

But all the other records are on different pages of the forms.

[This message has been edited by Elise_L (edited 07-25-2000).]
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:30
Joined
Feb 19, 2002
Messages
43,424
You don't need a loop to do what you are doing. Put your code in the OnCurrent event of the form. This event is executed every time a new record is displayed.

Private Sub Form_Current()
If Material = "composites" Then
ChkComposites = True
End If
If Material = "metal" Then
ChkMetal = True
End If
End Sub

I would like to offer a suggestion though. One of the reasons for the popularity of Windows applications is consistancy. We have come over the years to expect certain types of behaviour from certain objects. Using checkboxes as you have could confuse the users of your form. You are using multiple checkboxes to hold a single piece of information - material type. Each checkbox must be mutually exclusive (you can't have more than one checked). To make them behave this way you would need to add additional code or place them in an option group.

If you use an option group (preferably with radio buttons rather than checkboxes), you can use a bound field and Access will provide all the "behind the scenes" code to manage the mutually exclusive nature of the options. However, using an option group will require that you come up with a numeric code for material type. If you decide to go that way, post again and I'll expand.
 

Elise_L

Registered User.
Local time
Today, 21:30
Joined
Jul 19, 2000
Messages
13
Thank you for your your response, but what you were saying about it being mutally exclusive, I don't want that do I?? Several of the boxes may be checked. There could be up to 5 possibilities per ID, which is the problem I have.

Your suggestion of using Form_Current does enable each of the check boxes as you scroll through them, which is a start (Thank You), but the next part of it of having them all load up automatically without the need for scrolling is what I want to do, that's why I though I need a loop, so it could read each record, and check the answer.

(See also my post Checkboxes, and displaying records from last week)

[This message has been edited by Elise_L (edited 07-26-2000).]

[This message has been edited by Elise_L (edited 07-26-2000).]
 

Users who are viewing this thread

Top Bottom