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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Main form - two subforms - visibility issues...

Status
Not open for further replies.

shortone

Programmer
Mar 6, 2002
45
US
Hi,
Without getting into the long, sordid story as to why, suffice it to say that I have a data entry form that contains static data from a union query. Linked to the main form are two subforms linked to one of the two queries upon which the union query is based. Before the form loads, the user will give the unique identifier ("SP") to the particular record in which they wish to enter data (based on Fiscal Year - one query is for all records before 7/1/02, and the other starts with 7/1/02). What I would like to happen, is to have the subform open or made visible that corresponds to the SP entered. The code I have written is below:

Code:
Private Sub Form_Load()
On Error GoTo Err_Form_Load

    If Forms!SectyEntryForm!SP < 2030000 Then
       [Forms]![SectyEntryForm]![2003SectySubform].Visible = False
       [Forms]![SectyEntryForm]![EntrySectySubform].Visible = True
    Else
       [Forms]![SectyEntryForm]![2003SectySubform].Visible = True
       [Forms]![SectyEntryForm]![EntrySectySubform].Visible = False
    End If

Exit_Form_Load:
    Exit Sub

Err_Form_Load:
    Resume Exit_Form_Load

End Sub
I have the subforms in the same place on the form, they are the same color and contain the same fields, so that the user won't notice any difference in forms when entering the information.

The older records subform {&quot;EntrySectySubform&quot;} works fine and I can enter that information, but the problem I am running into is when I enter an SP number greater or equal to 2030000. &quot;EntrySectySubform&quot; stays on top and I can't get to &quot;2003SectySubform&quot;. Am I going about this the wrong way (I must be, because it's not working)? I have to get this up and running by next week and, of course, I was given this assignment earlier this week, along with a number of other projects... sorry, had to vent there. Anyway, if anyone has a better idea, or needs more information from me, please let me know - I'm taking a break from this now. Thanks in advance!
[bugeyed] JayeD
&quot;I'm sure of two things: there IS a God, and I'm NOT Him!&quot; - R. Williams
 
One place where I have been caught out before is with the correct referencing of the subform. Is 2003SectyForm the name of the actual form you are using as a subform, or the name given to the subform control within which it sits on the mainform? It should be the latter.... Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Nigel,
I think I need a vacation - that was it!! I clicked on the subforms to check the names and they DIDN'T match the names in the code (there were spaces). I deleted the spaces, saved & closed, then re-opened it twice, using a different number each time and it worked! Thank you so very much, you're brillant!!

[wavey3]
JayeD
&quot;I'm sure of two things: there IS a God, and I'm NOT Him!&quot; - R. Williams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top