Solved

Refreshing the dtaagrid and related controls

Posted on 2000-03-19
3
167 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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