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

Disabling Tabs in a form 1

Status
Not open for further replies.

aaabuhalime

Instructor
Nov 22, 2012
67
US
Hi,
I have two forms, the first form has two Categories lists (Morning and Evening ), the second form has multiple tabs(Page 1, Page 2, Page3....etc), on the first form the times listed under each category for example ,
Morning
1 am
2 am
3 am
Now when I click on any time it opens the second form, what I want to do is when I click any time I want the second form to open with specific pages disabled based on the time, for example, when I click on 2 am I want the second form to open with pages 2 and page 3 disabled. I need help to be able to that , I can make copies of the form and customize based on each slection but I will end with many copies, is there any way to do it through a program, if so where I need put the code, on the first form or second.

Any help will be appreciated.

Thanks
 
Don't make multiple copies. Use the OpenArgs of DoCmd.OpenForm to send information to the second form about which tabs should be disabled.

Try it and come back with questions.

Duane
Hook'D on Access
MS Access MVP
 
ok I have the following code to open the second form based on a specific criteria

Code:
Private Sub Command1_Click()

Dim strDocName As String
 Dim strWhere As String
 strDocName = "form2"
 strWhere ="[ID]=[Forms]![form2]![ID] And [Name]="Student"
 DoCmd.OpenForm "strDocName", acPreview, , strWhere

End Sub


And on the second form under on current I have the following code
the second form
Private Sub Form_Current()

Code:
Select Case Me.Name
Case "Student", "Teacher"
   Pagename1.Enabled = True
   Pagename2.Enabled = True

Case Else
 Pagename1.Enabled = False
   Pagename2.Enabled = False
End Select
End Sub

Am I on the right track ? please advise, again what to do I want to open the form based a specific selection also disable specific tabs as well based on the selection.

Thanks
 
I would think the where statement does not makes sense, because I would assume the ID uniquely indentifies a record to open. So should it simply be?

strWhere = "[ID]= " & me.id

also I doubt you can use "Name" as a field name. When you do this
Me.name that is going to return the name of the form. You might be able to get away with
Me![Name] but bottom line that is a poor choice for a field name.

I would think if you open it to a specific ID one of the fields in the record would have the value for 'student'. So I do not think you need to pass it, but your select case is the right approach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top