PDA

View Full Version : access help



sindhuja
06-30-2008, 04:51 PM
hi,
I want to display different forms depending upon the value selected in the combo box. For ex, if i select group3 in combobox, frmgroup3 should be displayed in the frmfeeds... similarly for the other values...
Also i want to add the values that i enter in the form and save it in the already existing table.
thanks,
Sindhuja

OTWarrior
07-01-2008, 06:57 AM
Looking at your sample, I would remove Frame20 from your frmFeeds, and replace it with a subform.

When you select an option from the drop down menu, you should be able to change the source object of the form, to change to a different form.

If all of your forms are similar however, you may find it easy to use multiple queries to display different data, rather than having lots of different forms.

Hope that helps.

sindhuja
07-01-2008, 12:15 PM
Thanks Warrior, but am not clear as I am new to access.

Can you please let me know how to change the source object of the form, to change to a different form with a sample.
Detailing this will help me in understanding better.

Thanks in advance,
Sindhuja

OTWarrior
07-02-2008, 12:06 AM
No worries, this may be what you are after:

me.frmSubfrm.SourceObject = SubFormName
me.frmSubfrm.requery

note, in order to change the source of a subform, you have to make a direct reference to it from the parent form.

(SubFormName being the variable for the name of your new form.)

so you might have (guessing here):


dim SubFormName as string

select case me.ctlDropDown.value

case 1:
SubFormName = subFrm1
case 2:
SubFormName = subFrm2
end select

me.frmSubfrm.SourceObject = SubFormName
me.frmSubfrm.requery

sindhuja
07-02-2008, 04:58 AM
Thanks Warrior !

One more query !
Do I need to overlap all the subforms in the mainform and make invisible intially. Depending upon the selection in the bank account combobox I need to show the subform.

Else, depending upon the selection I should call the subform in the after update event of combobox.

Am not sure which method will be effective. I guess yu have suggested the second method.

Kindly shed some advise on this?.

Regards,
Sindhuja

OTWarrior
07-02-2008, 06:31 AM
with the code above you only have one subform open at any one time.

You COULD make all the subforms invisible, but I often find this makes the loading of the main form alot slower.

the SourceObject changes the reference to the subform, effectly closing the current one, and opening up the one you are requesting.

Hope that makes sense.

sindhuja
07-02-2008, 01:52 PM
Thanks Warrior !

Let me try this and get back to you if i face any issues or difficulties....

Regards,
Sindhuja