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

ADODC Question???

Status
Not open for further replies.

goatsaregreat

Programmer
Mar 21, 2001
82
GB
I want to be able to change the recordsource of an ADODC control through code. For example, I have a large DB with numerous tables - each representing one year for the last 15 or 20 years- and I want to allow the user to choose a year via a combo box or some other way, and have the ADODC's recordsource property changed to the corresponding table. Is something like this possible? I am using a grid control to display data, and I would like for that to update as well. Please help. The sooner the better. ;-) If you need more info on what I am trying to ask, please let me know. TIA
 
On the combobox's click or lostfocus function, put a series of if statements that say if combo.text = 1999 then recordset = correct table. That should work, but put a post here if you need more help.

Brian
 
I don't use the Control, I code all of my connections. I might can help you get on the right path though. Hopefully I can.

Private Sub Combo1_Click()
Grid.Clear
Select Case Combo1.Text
Case "1999"
Adodc1.Recordset = "TableName"
Load Grid
Case "2000"
Adodc1.Recordset = "TableName"
Load Grid
End Select


Rob
Just my $.02.
 
anytime I put the line of code... ADODC1.recordset into any place in the code, I get an error message saying, "Invalid use of property." What in the world is going on????? TIA for your continued help.
 
The property may not be able to be set at runtime. I haven't used the adodc control so I really can't say. Sorry. Rob
Just my $.02.
 
The following came from a name signed "Jim in Cleveland". He said this would work. You may want to try it. I found it on another site.


I just set up a from with an adodc. I did not set any of the
properties for the adodc at design time. Added a CommandButton. Run
project, no errors. Press button and run this code:

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Persist Security Info=False;" _
& "Data Source=C:\Program Files\Microsoft Visual
Studio\VB98\rob2.mdb"
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "PL"
Adodc1.Refresh
MsgBox Adodc1.Recordset.RecordCount

Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top