473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

display data in datagrid using adodc through code in depending on query

1
hello sir, m using 4 combo boxes,2 option buttons,button.wen option named single type is clicked data grid must show the data i selected in combo boxes,wen all type option button is clicked then grid shows the all rows in access table.but both option buttons shows all rows in grid the code i have used is
Expand|Select|Wrap|Line Numbers
  1. Dim rsname1 as recordset
  2. Dim conn As Connection
  3. Set conn = New Connection
  4. conn.Open "provider=Microsoft.jet.OLEdb.4.0;Data Source=C:\Documents and Settings\admin\My Documents\medical.mdb"
  5. Set rsname1 = New Recordset
  6. rsname1.Open "select * from MASTER order by [PRODUCT NAME]", conn, adOpenDynamic, adLockPessimistic
  7.  
  8.  
  9. If Option2.Value = True Then
  10.     rsname1.Close
  11.     Set rsname = Nothing
  12.     rsname1.CursorLocation = adUseClient
  13.    rsname1.Open "select * from MASTER order by [COMPANY NAME],[PRODUCT NAME],[PRODUCT TYPE],[PRODUCT SIZE]"
  14.  
  15.    Form3.DataGrid1.DataMember = ""
  16.    Set Form3.DataGrid1.DataSource = rsname1
  17.    Form3.DataGrid1.Refresh
  18.     rsname1.Requery
  19.  
  20. ElseIf option1.Value = True Then
  21.    rsname1.Close
  22.    Set rsname1 = Nothing
  23.    rsname1.CursorLocation = adUseClient
  24.  
  25.    rsname1.Open "select * from MASTER where [COMPANY NAME]='" & Combo1.Text & "' and [PRODUCT NAME]='" & Combo2.Text & "' and [PRODUCT TYPE]='" & Combo3.Text & "' and [PRODUCT SIZE]='" & Combo4.Text & "', conn, adOpenDynamic, adLockPessimistic"
  26.  
  27.  
  28. Form3.DataGrid1.DataMember = ""
  29. Set Form3.DataGrid1.DataSource = rsname1
  30.    Form3.DataGrid1.Refresh
  31.     rsname1.Requery
  32. End If
  33.    End Sub

till now u might understood the problem m facing.actually problem is with option 2 ie single type.after clicking the command button values must appear in grid.
the error msg m getting is object r variable not decalred.please help me sir
thank u
Sep 25 '07 #1
1 5260
fplesco
82
till now u might understood the problem m facing.actually problem is with option 2 ie single type.after clicking the command button values must appear in grid.
the error msg m getting is object r variable not decalred.please help me sir
thank u
Hi -

Your problem is rsname. It was declared as rsname1. See font emphasized below.

If Option2.Value = True Then
rsname1.Close
Expand|Select|Wrap|Line Numbers
  1.     Set rsname = Nothing
  2.  
rsname1.CursorLocation = adUseClient
rsname1.Open "select * from MASTER order by [COMPANY NAME],[PRODUCT NAME],[PRODUCT TYPE],[PRODUCT SIZE]"

Form3.DataGrid1.DataMember = ""
Set Form3.DataGrid1.DataSource = rsname1
Form3.DataGrid1.Refresh
rsname1.Requery

Just change that to
Expand|Select|Wrap|Line Numbers
  1. Set rsname1 = Nothing
and its good to go.
Sep 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Peyter | last post by:
I am trying to populate the standard vb ListBox control with an adodc control but it is not succeeding. I know that the adodc control is set up properly because if I connect it to a DataGrid...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
2
by: Jason (Kusanagihk) | last post by:
To all, I am writing a C# application; I've a DataGrid to show and edit data; then I tried to update the updated data by calling ADO_Adapter.update (ADO_DataSet, "TableName"); But it pop up a...
4
by: Joe Van Meer | last post by:
Hi, Is the datalist meant for one table or can I use it to display information from 2 different tables? Or should I be looking at a datagrid instead? I began my code and kinda ran into a snag...
2
by: Steven Smith | last post by:
Hi guys What I'm trying to do today is display the results from an SQL query on one table in a Datagrid I'm using the following code to query the table. \\\ Try If...
1
by: priyanka.freakout | last post by:
Hi All, In my form I have created a dropdown box which is populated with data from a database on page load and i have also created a dropdwon box and what i intend on doing is displaying data...
2
by: Cindy | last post by:
Hello. For some reason, I am able to "connect" to the Northwind database whenever I use the wizard; however, when I run the application, my datagrid does not display. Here are the exact steps I...
3
by: phil67b | last post by:
Hello everybody, I have a page rech.php where I'm doing a multi-criteria research Ex. choose your car model, choose your country. After validation of my form, on the same page, the lines will be...
3
by: manjeetgrang | last post by:
in my form i have datagrid and adodc. i set adodc 's porperty and data grid well. all data is displaying well in grid. but i now wan selected data in grid (say for a particular date only) i am doing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.