Opening Sub forms with Command Button (1 Viewer)

Sander

Registered User.
Local time
Today, 18:15
Joined
Jun 6, 2001
Messages
20
I asked this question before and thanx to charityg, it's working but only partially. I have a form with 9 invisible subforms on it. One of the fields is a combobox named Models (Hence on the main form it is Models1, on the first subform it is Models2, etc). What I want to do is if the field models is filled in on the main form and I hit a command button that the 1st subform becomes visible. That's the part that works. Now for the part that doesn't. Once that button is hit, I want to be able to hit the button again and have it check to see if the Models field is filled in on the 1st subform. If it is then I want to make the second subform appear. And I want this to keep happening so that all 9 subforms can appear if the command button is hit the appropriate number of times. This is my code so far (I'm trying to take this in steps to make sure everything is working before I go too far).

If Not IsNull(Me!Models1) Then
Me!sub2.Visible = True
ElseIf Not IsNull(Me!sub2.Models2) Then
Me!sub3.Visible = True
End If

The thing is it does work to bring up the 1st subform (known as sub2), but it doesn't work from there. What's even more frustrating is that I don't get any type of error message, it just doesn't do anything. Any help is very much appreciated!! Thank you in advance!
 

D-Fresh

Registered User.
Local time
Today, 18:15
Joined
Jun 6, 2000
Messages
225
Try a loop...

if not isnull(me!Models1) then
me!sub2.visible = true
end if

for ctr = 2 to 9
if not isnull(me("sub" & ctr)("Models" & ctr)) then
me("sub" & (ctr+1)).visible = true
end if

Since the syntax of the first text box is different, you have to check that seperately, then run through the loop for 2-9. Hope that helps.

Doug
 

Users who are viewing this thread

Top Bottom