I'm looking for vba code to enable within MS Access to have the same form to use different datasets. The requirement is to allow the user to switch between one month to another looking at the same form. The datasets are going to be stored within Access by month. Each passing month will get a new dataset stored to the database. The user while in the form will need to be able to view any month they select.
same form uses different datasets
Collapse
X
-
Tags: None
-
You don't really need VBA to do that
However
in the appropriate event
[code=sql]
me.recordsource ="Select theFieldList from theTable where month=selectedm onth"
me.requery
me.refresh
[/code]
You probably don't need to me.requery
I put it there to cover all bases
You will need to provide
theFieldList
and theTable
and selectedmonth
according to your needs -
Storing separate months in separate datasets (I presume you mean tables) is not a good idea (See Normalisation and Table structures).
The way this should be handled is by applying a simple filter to the opening of the form. Changing the filter can be done in VBA while the form is still open if required. Otherwise, a differnt call to open the form just passes the required filter.Comment
Comment