|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Access 2007 Combo Box within Form
Hi There,
I'm a bit of a novice in terms of access 2007 and know nothing about VBA. I was hoping someone could help me out with I have created a table called Membership. It's fields include firstname, lastname, address, telnumber, Membership_Type and Group_Membership_ Type etc . I have also created a form from this table. In this form Membership_Type and Group_Membership_Type are Combo Box. Their Row sources are (Individual and Group) and ( Collerative, sustaining and patron) respectively. I want to make "Group_Membership_Type " visible only when Membership_type = "Group" To accomplish this I have written code at the change event of membership_Type Like this : Private Sub Membership_Type_Change() If [ Membership].[Membership Type] = "Group" Then [ Membership].[Collective Membership Type].Visible = "true" Else [ Membership].[Collective Membership Type].Visible = "false" End If End Sub I am not able to get the result. Can someone please tell me how it's done? sorry if it sounds a little simple to some of you, but it your reply would be very helpful. thanks |
|
#2
|
||||
|
||||
|
Posted in error
|
|
#3
|
||||
|
||||
|
Code:
Like this : Private Sub Membership_Type_Change() If [ Membership].[Membership Type] = "Group" Then [ Membership].[Collective Membership Type].Visible = "true" Else [ Membership].[Collective Membership Type].Visible = "false" End If End Sub Think you need to change to AfterUpdate event and Code:
If me.membership_Type ="Group" Then me.Collective_Membership_Type.visible= True Else me.Collective_Membership_Type.visible = False End if A suggestion for field names. Avoid using spaces in field names. It will only cause aggravation in the future. You need to remember to either square bracket or use underlines. If you use a convention like MembershipType or CollectiveMembershipType you are less likely to have coding issues in the future. Alan |
|
#4
|
|||
|
|||
|
Access 2007 combo Box Within Form
Alan, Thank for the suggestion. Code works fine, but I like to know why I need to use "Afterupdate" event.
Thank you Bijaya |
|
#5
|
||||
|
||||
|
I use afterupdate because I want the script to fire after I move to the next control, ie. leave the control that has the script.
Alan
__________________
Alan Sidman __________ If I helped you, I'd like to know. Click on the icon next to the thread number and tell me. |
|
#6
|
|||
|
|||
|
Access 2007 ComboBox Within Form
Thank you AlanSidman for your tesponse.
Bijaya |
|
#7
|
|||
|
|||
|
Combo box on subform
I'm new to access 2007 forms and I'm sure this is an easy question
I want to pick a program in one box, the other box gives the matching price. The boxes are on a subform bound to an invoice table. The program-price combinations are on a seperate lookup table (thec_Program). This code works on the subform on the price box: SELECT THEC_Program.Program_Cost, THEC_Program.ID, THEC_Program.Program FROM THEC_Program WHERE (((THEC_Program.ID)=[Forms]![SUBFORMNAME]![Program])); When a tab in the main form get a parameter error, so changed to this SELECT THEC_Program.Program_Cost, THEC_Program.ID, THEC_Program.Program FROM THEC_Program WHERE (((THEC_Program.ID)=[Forms]![FORMNAME]![Program])); I'm new to access 2007 forms and I'm sure this is an easy question: I want to make a selection in one combo box and have the other show the matching info (program => program_cost). The bound boxes are on a subform for an invoice table. The program-price combinations are on a seperate lookup table Thec_Program. This code on the program_cost box works when only the subform is open : SELECT THEC_Program.Program_Cost,THEC_Program.Program, THEC_Program.ID FROM THEC_Program WHERE (((THEC_Program.ID)=[Forms]![SUBFORMNAME]![Program])); When the full form is open, the subform is a tab and the above code returns a parameter error it doesnt recognize the subformname. So I chage to this: SELECT THEC_Program.Program_Cost, THEC_Program.ID, THEC_Program.Program FROM THEC_Program WHERE (((THEC_Program.ID)=[Forms]![FORMNAME]![Program])); No parameter error but the drop down is blank.... Why is query coming back blank? I have an AFTERUPDATE on the program box. On the subform this allows for multiple changes. Private Sub Program_AfterUpdate() Me.Program_Cost = Null Me.Program_Cost.Requery Me.Program_Cost = Me.Program_Cost.ItemData(0) Thanks for any help. Thanks for any help. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Database Development > Access 2007 Combo Box within Form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|