Solved

Refreshing the dtaagrid and related controls

Posted on 2000-03-19
3
166 Views
Last Modified: 2012-05-04
In this small snip of code, I am trying to clear the current recordsource,recordsets of the data control and the data grid. And I want to be able to reset them as something else, when chosen by the iser. I hope this makes some sense. How do I go about doing this?

------------------------------------------------------


 'reset/clears datagrid before conducting search
    Set grdDataGrid.DataSource = Nothing
   
    'grdDataGrid.ReBind             do I need this?
    grdDataGrid.Refresh
       
    'closes recordset to close the previous query/datasource
    If datPrimaryRS.Recordset.State = adStateOpen Then
        datPrimaryRS.Recordset.Close
    End If
    datPrimaryRS.RecordSource = ""
   
    'resets the query building string
    sSQL = ""       'query variable
    qFlag = 0       'query flag
   
               
    'starts the search
    'creates new recordset to be used as search string(query)
    If datPrimaryRS.Recordset.State = adStateClose Then
        datPrimaryRS.Recordset.Open
        datPrimaryRS.Recordset.Requery
    End If
   
    Command4.Visible = True     'shows print button
0
Comment
Question by:slimbx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
Voodooman earned 25 total points
ID: 2635452
Hi!

You dont really need most of this.

You dont need to close rec sets etc.

'Just get the SQLstring and set it as 'the record source

datPrimaryRS.RecordSource = Sqlstring
datPrimaryRs.Refresh

'Tell the user if no records found
'**********************************
'the datagrid will be empty
'****************************
if rsPrimaryrs.recordset.recordcount=0 then
msgbox "No records found matching your criteria"

'Record sets automatically close when you close the form bound grids automatically refresh - you can rebind if you have a problem
'******************

Good Luck
Voodooman!

 
     
   
0
 

Author Comment

by:slimbx
ID: 2636585
Thanks much Voodooman.

slimbx
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2636925
Thanks for the points.

There are lots of people on the site who refuse to give points for good answers (because they are saving them). This is unfair and puts people off answering - I answer for the buzz of getting the points - if i dont get points its a waste of time.

Good luck with your VB.

Remember in General terms all objects close when you close a form - no need to close them.

Voodoman
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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