?
Solved

change datasource for grid on timer event

Posted on 2007-10-01
5
Medium Priority
?
266 Views
Last Modified: 2008-01-09
I have a form that has a gridview on it.  I would like to have a timer event that fills the datagrid with dataset1 and then on timer next fire would fill datagrid with dataset2
Here is the code that I used in access for this same procedure...

Static B As Boolean
If B Then [Forms]![myform1].Form.RecordSource = "rs" Else [Forms]![myform1].Form.RecordSource = "rs2"
B = Not B
0
Comment
Question by:H-SC
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
MrRobot earned 2000 total points
ID: 19992973
hi,

put a timer control on the form, and on it's event, use this code, which myDataSet, myDataSet2 are public variables, created before.

*****

dim b as boolean

if b then
   myGrid.datasource = myDataSet
   myGrid.datamember = "myTable"
else
   myGrid.datasource = myDataSet2
   myGrid.datamember = "myTable2"
end if
b = not b

****

rob
0
 
LVL 8

Expert Comment

by:MrRobot
ID: 19993035
oops, it should be

static b as boolean

instead of

dim b as boolean
0
 
LVL 1

Author Comment

by:H-SC
ID: 19993727
rob,

many thanks for the response... this works perfect!!  Also if I wanted to apply this same code to the datasource of a form, how would that look?
0
 
LVL 8

Expert Comment

by:MrRobot
ID: 19994554
you're welcome =)

a form doesn't have a datasource, but I think you mean datasource of a grid on another form, than the code will simply be;

myForm.myGrid.datasource

0
 
LVL 1

Author Comment

by:H-SC
ID: 19998194
sounds great rob....many thanks again
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question