data grid scrolls with main adodc contrl

captain27
10-19-2004, 12:32 AM
I have one adodc1 control and a coded adodc connection (adodc2). adodc1 controls the sstab with four tabs. adodc2 controls a data grid within one of the tabs. when i scroll with the main adodc1 the records move based on the primary key called spaceno. well what I would like is to have the datagrid show the information only for that spaceno currently displayed. I have tried putting this on the form load but it only shows the first and does not move when you scroll the main adodc1 control
-----------------------------------
Public Sub accountlistload()
Dim sSql As String
Dim rsInformation As New ADODB.Recordset
Dim mCnn As New ADODB.Connection

Dim strConn As String
mCnn.Open "mhp"

sSql = "SELECT * FROM accountlist WHERE spaceno = " & Trim(Val(spaceno1.Text))
rsInformation.CursorLocation = adUseClient
rsInformation.Open sSql, mCnn, adOpenDynamic, adLockOptimistic

Set DataGrid1.DataSource = rsInformation
Set rsInformation = Nothing
Set mCnn = Nothing
End Sub
-------------------------------
this code is for adodc2. adodc1 is not setup with code but using the properties setting.

Dennis DVR
10-21-2004, 05:16 AM
i don't quite understand your problem, the code you've posted is a native ADO object and not a data control. Can you elaborate a little bit, if you want to automatically scroll the datagrid when the adodc is being move where your datagrid is being bound to, you can use the scroll method of datagrid control.

btw: if you know how to code and use the ADO object, you should switch to ADO completely instead of using Data control.

NEOLLE
10-21-2004, 05:59 AM
hello captain27,
Where do you call your AccountListLoad procedure?, and you can do away with your ADODC1. You already have ADODC2 (which is coded). You can do a lot of things with that. :)

captain27
10-21-2004, 12:00 PM
I have my accountlistload under form_load function. I have alot of events that are based on adodc1 so it would be time consuming for me to change it now. How do I use the scroll method for datagrid simutaneiously with the adodc1 control scroll. I tried putting the accountlistload under the adodc1 movecomplete function but that did not work.
Thanks

captain27
10-21-2004, 12:01 PM
I have my accountlistload under form_load function. I have alot of events that are based on adodc1 so it would be time consuming for me to change it now. How do I use the scroll method for datagrid simutaneiously with the adodc1 control scroll. I tried putting the accountlistload under the adodc1 movecomplete function but that did not work.
Thanks

Dennis DVR
10-21-2004, 10:28 PM
I have my accountlistload under form_load function. I have alot of events that are based on adodc1 so it would be time consuming for me to change it now. How do I use the scroll method for datagrid simutaneiously with the adodc1 control scroll. I tried putting the accountlistload under the adodc1 movecomplete function but that did not work.
Thanks

if datagrid is bound to a datacontrol then it should automatically scroll when the record pointer points to non visible rows.

can you tell us exactly your situation? is datagrid bound to adodc1? because if it is then the datagrid should automatically scrolled without any additional code, or it is bound to adodc2? if this is the case, can you explain the relation of these 2 data controls?

captain27
10-22-2004, 10:59 AM
ok well datagrid is bond to adodc2 But i already figured it out. thanks guys.

solution:
change this line:
sSql = "SELECT * FROM accountlist WHERE spaceno = " & Trim(Val(spaceno1.Text))

to this line:
sSql = "SELECT * FROM accountlist WHERE spaceno = " & Adodc1.Recordset("spaceno").Value

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum