Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Refresh Datagrid According To Combo Box ?


Hi,

In one of my forms I have a Combo Box with certain category names. I also have a Datagrid. I want that as the user clicks for an option in Combo Box the Datagrid should be refreshed accordingly with different queries. How to do this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
URGENT SOLUTION NEEDED! Datagrid Add New Record, Refresh Unbound Combo Box.
Hi,

although I hate adding "URGENT" in the subject, this time the deadline is very close.

These are two topics that have not been answered so far, but I think that they rather common problems and I wonder why nobody has tried to look at them seriously!

1. In the attached VB6 project, I encounter the problem that a newly added record disappears from the datagrid. Click next to the * that denotes a new record in the datagrid, add a new record, move to a different row and find out that the row disappears. If you rerun the project, the row is there. It has to do with the rs.filter command but still can't figure out why it behaves like this and how to remedy the problem.

2. The other problem has to do with how to refresh an unbound combo box. I have an unbound combo box that is filled with names from a table. It is used for selecting a name and then navigating to the selected record. When, a new record is added, or an existing record is modified, or a record is deleted, the unbound combo box is not refreshed.

Could anyone please offer his experience into any of the above?

Thanks in advance for your prompt replies...

Best regards,

John.



Edited by - jnk on 11/3/2003 5:34:59 AM

Refresh DataGrid(Microsoft DataGrid Control 6.0)
Hi,

I am having a problem refreshing the datagrid in the following scenario:

I have Form1 with ADODC control and DataGrid(Microsoft DataGrid Control 6.0). The grid (is used to display employee records) contains 5 columns (for example Office telephone number) . On clicking of a row on the grid the details window opens up. This window is used to update the employee information. On saving the employee record if Office telephone number is changed then the datagrid should be refreshed with latest data of the record. The refresh is done using the following command:
msgbox "activate"
adodcobject.refresh
datagridobject.refresh.

If the message box is commented then the refresh statements do not get executed. I need a solution for that.

Regards,
Rashmi.

DataGrid Refresh
Hi to all...it's me again.

THis time i have a problem with the DataGrid control. At design time I have binded the DataGrid to an ADODC control with a SQL statement to retrieve some fields from a Database.

Now during execution, I want the datagrid to retrive new records depending on the employee code given by the user. What i'm doing is i'm reading the recordset, set the adodc to the new recordset and then refresh the datagrid..but nothing is happening. When i count the rows (with the recordcount) i'm getting 2 rows, but in the datagrid nothing appears. Below is the code i'm using

Dim rstPre As Recordset
Set rstPre = New Recordset

StrSql = "SELECT * FROM [PreTax] where EmpID like '" & UCase(txtEmpCode.Text) & "'"

rstPre.Open StrSql, "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= " & App.Path & ("/DB1.MDB"), adOpenKeyset, adLockOptimistic, adCmdText

Set PreTax.Recordset = rstPre
DgrdPreAllow.Refresh

Your help is appreciated......i'm desperate...i have 5 other datagrids working in the same way...please help

Datagrid Help Refresh Row Only
Hi All,

I have an issue im hoping someone can help with. I have a datagrid on which I can update a selected row. But in order to see the changes applied to this row i have to refresh/rebind the WHOLE Grid.

I dont want to do this as it resets the current grid/view.

Is there a way to just update a specific row with out the whole grid needing to be refreshed/rebind??

Ive attached as picture of the row I just want to update

thanks
Brendan

How To Refresh DataGrid?
In my form I have a DataGrid which is connected to
the DataEnvironment to display selected records.
I have a command button named "Save" which when
clicked saves a new record in the table.

I want that as the user clicks the "Save" button
the DataGrid should be updated immediately to
reflect the new record.

I have tried "ADODC" also, but nothing is happening.

How to refresh the DataGrid?

DataGrid Refresh
Can anyone help?

Can anyone see why my datagrid will not refresh and show the new add? All it does is a quick flash on the screen, but doesn't update the grid. If I leave the form and reload it, it is updated with the added record


Private Sub cmdSave_Click()

Select Case cmdSwitch.Caption
Case "&Vendor"
Adodc1.Recordset.Update
cmdAdd.Caption = "&Add"
frmProList.Adodc1.Refresh
frmProList.DataGrid1.Refresh
EnableVendor False
cmdFirst.Enabled = True
cmdBack.Enabled = True

Case "&Product"
With Ven_Prod.Recordset
!Pro_ID = txtProdID.Text
!v_p_catalog = txtVenCat.Text
.Update
End With
dbVenProd.Refresh
dbVenProd.Recordset.Requery
DataGrid1.Refresh
dbVenProd.Recordset.Filter = "pro_id = '" & Format(txtProdID.Text, "0000") & "'"
cmdAdd.Caption = "&Add"
cboVen1.Text = ""
txtVenCat.Text = ""
txtPrice.Text = ""
EnableVendor False

End Select

cmdSave.Enabled = False
cmdSwitch.Enabled = True

End Sub

I have checked other postings on the subject, but didn't see anything that helped.
any input is appricated

Refresh Datagrid
Hi all!

I have a datagrid on my main form that is connected to an Access database with Adodc. I have a button that opens up another form to ask the user if they want to print the information or save it, along with a cancel button to simply close the form.

If the user clicks on "Print" or "Save" the code works fine but then I want it to return to the main form with nothing showing in the datagrid.

I tried to refresh the adodc from the second form before closing it, but it does not affect the datagrid in my main form. I also thought about refreshing the Adodc in the GotFocus event of the main form but then it would also refresh when the user hits cancel.

Does anyone have any ideas? Thanks!

Refresh DataGrid
I have a datagrid I want to refresh based on what is choosen in a combo box. I hope I'm over looking something simple. I get an error with the code below saying "Error near From clause".

Eric


Private Sub cmdFind_Click()

'refresh Deposit datagrid based upon text in combobox when Find Button is clicked
Dim pstrSQL As String

pstrSQL = "Select * From tblMarkDeposit " & _
"WHERE fldAccount = '" & _
cmbAccountNum.Text & "'"

'These two statements rebuild the recordset.
adoDeposit.RecordSource = pstrSQL
adoDeposit.Refresh

End Sub

Refresh Datagrid.
Hi peepz.

My problem :
I have 2 forms, one has a datagrid which shows a recordset. the other one is used for adding values to the recordset, but when i add a value to the recordset (same one as the one used to fill the datagrid) the datagrid doesn't show any records anymore.

I tryed refreshing the datagrid, but that didn't work eighther. (after searching through the forum found out i'm not the only one with this problem, but i didn't see an anwser anywhere.)

There has to be a way to refresh the datagrid, i tryed to refill it when the form gained focus again, but cause i'm using an MDIform that didn't work eighther . The Getfocus didn't execute when the form gained focus.

anyone any other idea ??

Ty

VB6: Refresh Datagrid
How can I refresh a DataGrid?

I've tried Me.DataGrid1.Refresh, but that's not working.

The DataGrid gets it's data from a Saved Command in my Data Environment, however, after deleting a record from the table, I need to refresh the datagrid to show the updated list of records.

Thanks In Advance.

Refresh Datagrid In VB 6.0
Hello everyone,

I'm new to vb and this forum. I need help from anyone please. I've looked through the posting but I cannot find an answer for my problem. My problem is refreshing a datagrid after I delete a row. Below is the code that I am using. I have tried various suggestions but nothing seems to work.

Again any help would be appreciated. Thanks in advance.

UTDEL

Private Sub cmdDelete_Click()
Dim pstrSql As String

Dim pstrPartNum As String
pstrPartNum = InputBox("Enter part number to delete", "Exercise 1 - Delete Part Number")
If StrPtr(pstrPartNum) = 0 Then
Exit Sub
End If

If Val(pstrPartNum) Then
pstrSql = "DELETE * FROM tblInventory " & _
" WHERE fldPartNum = " & pstrPartNum
' MsgBox pstrSql
mcmdCurrent.CommandText = pstrSql
mcmdCurrent.Execute

pstrSql = "SELECT * FROM tblInventory " & _
"WHERE fldCategory = " & mstrCategory
adInventory.RecordSource = pstrSql
adInventory.Refresh
dgInventory.Refresh
MsgBox "Part Number " & pstrPartNum & " deleted", vbInformation + vbOKOnly, "Exercise 1"

Else
MsgBox "Must enter a valid part number", vbCritical + vbOKOnly, _
"Invalid Part Number"
End If
End Sub

Datagrid Refresh
I have a datagrid that display some values from my mssql server.
I want to insert some new lines in my database and I doit with
one sql insert command.


VB Code:
strsqlins = "insert into mistake " & _               "(aa,whip,whname,whdate,calculate) " & _               "values ('" & AA & "', '" & Txtwhip.Text & "', '" & txtwhname.Text & "', '" & m & "', " & chkcalculate.Value & ")"    cnConn.Execute strsqlins    DataGrid1.ReBind    DataGrid1.Refresh


Why the datagrid1.refresh command it dosnt work?
I must exit from my application so I can see my new data
The same thing hapens and with my update command and delete command.

So finally I want to know how to refresh my data.

Why Can't I Refresh The Datagrid ?
I insertted a new record and it is displayed in Access. But the datagrid in VB doesn't show it. Even I use datagrid.refresh , it doesn't work.

How Do I Refresh A Datagrid?
i have a datagrid showing fields in an acess database, and a field timediff that gets changed by my program, when i look in the database it is changed all good, but i wont show on the datagrid, i've tried requery on the recordset, refresh on the datagrid, and rebind on the datagrid, but still no changes, how do i do it?

ooh, also, the other fields showing are put in by the user straight into the datagrid, or were set when the grid was initialised, these all display fine, and save to the DB fine.

Datagrid Refresh
Hi all,

I use the data environment to retreive data from db and put them onto a datagrid.

everytime I start my application and the old result from the last time will also display on the datagrid. Seems like the result stays in memory!!!

someone suggest me to refresh my dataconection like
Data1.refresh

my data environment name is 'DEMAIN'
and the connection is named 'CONNECTION1'
I tried but found no such refresh command for them
the only thing I can refresh is the datagrid but it's not earsing the previous result.

Any suggestion?
Many thanks.

Datagrid Refresh
Hi all,

I use the data environment to retreive data from db and put them onto a datagrid.

everytime I start my application and the old result from the last time will also display on the datagrid. Seems like the result stays in memory!!!

someone suggest me to refresh my dataconection like
Data1.refresh

my data environment name is 'DEMAIN'
and the connection is named 'CONNECTION1'
I tried but found no such refresh command for them
the only thing I can refresh is the datagrid but it's not earsing the previous result.

Any suggestion?
Many thanks.

Datagrid Refresh
how to refresh the datagrid.

i have 3 combo boxes for user to click and choose to search for the specific data through searching MySQL database tables.

but after searching i wish to clear the selection user made. i have created a clear button to clear the selection that the user have made using the combo box.i could clear the combo box selection.

at the same time i wish to clear the data display on the datagrid but i could not.

i try writing code but can't ,can tell me what is wrong with it ??

Private Sub cmdELClear_Click()
cboEquipType.Text = ""
cboEquipCategory.Text = ""
cboEquipCode.Text = ""
adodcEquipList.Refresh
dgCustEquipList.Refresh
End Sub

Refresh DataGrid
I have 4 cols in my DataGrid1
EmplCode,EmplName,OccCode,OccDescr

Please,
when I change the 'OccCode' in DataGrid1 the table [Employees] is updated but the the next col 'OccDescr' that comes from the joined table [Occupations] is not refreshed right away!!!

Next is the way The Datagrid1 is initialized.

Private Sub Form_Load()
Set rsE = New ADODB.Recordset
rsE.Open "sELECT e.EmplCode,e.EmplName,e.OccCode, o.descr AS OccDescr " _
& "FROM [Employees] e " _
& "left outer JOIN [Occupations] o ON o.CODE = e.OCCUP order by e.EMPLCODE  " _
, cnWG, adOpenStatic, adLockOptimistic
        Set DataGrid1.DataSource = rsE1
'    End With
End Sub


How Do You Refresh A Combo Box
Is it possible to refresh a combo box by clicking a button, the reason is that i have the combo box hooked up to a database but the data does not update in the combo box until i restart the program, can i make a button to refresh the combo box, what is the code required, THANKS

Refresh And COmbo Box
Er.......I have just finished updating the database through coding in vb using DAO.recordset. After I type .update, followed by .close, i end with 'end with'.

beneath the textfields andbuttons i use to add, i have an msflexgrid to display the data from the database.
How do I update the msflexgrid too when the user presses the add button?

Combo Box Refresh
I am trying to populate a second combo box after a user selects an item from the first combo box. I can't figure out how to refresh the second combo box when the user selects a different item from the 1st combo box. Right now the combo box just keeps adding on and won't refresh




Code:
Private Sub cboDegreePlan2_Click()
'this subroutine will populate the flexgrid with the matching record

Dim rsPopInfo As adodb.Recordset
Dim strRs2 As String
Dim strRs3 As String


Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "catalog.mdb"

Set rsPopInfo = New adodb.Recordset

strRs2 = "SELECT CstCourses.Rubric FROM Degrees INNER JOIN CstCourses ON Degrees.DegreeID = CstCourses.DegreeID WHERE Degrees.CSTDegrees = '" & cboDegreePlan2.Text & "'"
'strRs2 = "SELECT BrandName from ChemicalList"

rsPopInfo.CursorType = adOpenDynamic
rsPopInfo.CursorLocation = adUseClient
rsPopInfo.LockType = adLockPessimistic
rsPopInfo.Open strRs2, strConn

'pass matching records
Set cboRubric.DataSource = rsPopInfo

With rsPopInfo
Do While Not .EOF
cboRubric.AddItem rsPopInfo.Fields(0)
.MoveNext
Loop
End With

cboRubric.Refresh

Combo Box - Where To Refresh
i wonder where to place cmb_subj_code.refresh within this code:


Code:
Private Sub cmb_section_Click()

Dim rsGetstudents As New ADODB.recordset
Set rsGetstudents = conn1.Execute("Select fld_subj_code from schedule_query " & _
"Where tbl_college_code.fld_ccode_desc = '" & cmb_course & "'" & _
"and tbl_offered_subj.fld_semester = '" & cmb_sem & "'" & _
"and tbl_offered_subj.fld_sch_year = '" & txt_syear & "'" & _
"and tbl_sched.fld_yearlevel = '" & cmb_yrlevel & "'" & _
"and tbl_sched.fld_section = '" & cmb_section & "'")



rsGetstudents.MoveFirst
Do While Not rsGetstudents.EOF


cmb_subj_code.AddItem (rsGetstudents!fld_subj_code)

rsGetstudents.MoveNext
Loop



rsGetstudents.Close
Set rsGetstudents = Nothing

the code works fine... the subjects are displayed in cmb_subj_code when i select a section.. the problem is, when i select a new section, the previous subjects on cmb_subj_code are still displayed together with the new subjects from the new section that i selected

Refresh Combo Box?
How do I refresh a combo box after deleting an item from my database?

Ex:
The user selects a name from the dropdown list which fill a form, and then clicks on a delete button which deletes the name from the db, but name still remains in the dropdown list.

I tried using "refresh" but this did not work.

Datagrid Refresh Problem
Hi, I have 2 datagrids on separate forms which read the same data but in different ways. My problem is when I update the datagrid on one form and then click on a button I want it to refresh the datagrid in the other form straight away and it isn't doing that. I don't understand why. If I update the data again and click the button then it does refresh the other datagrid but to the update that I had done before and not the new one. Here is the code that is linked to the button.

Private Sub cmdSave_Click()
If DGEdit.DataChanged = True Then
Dim strQuery As String
strQuery = "SELECT * FROM KeyFobStock WHERE Status = 1 ORDER BY KeyFob"
KeyfobList.Adodc1.RecordSource = strQuery
KeyfobList.Adodc1.Refresh
MsgBox "You update has been saved"
txtGetKeyFob.SetFocus
Else
MsgBox "No data has been changed. The update will not proceed"
End If

End Sub

KeyfobList is the name of the other form that contains the datagrid that I want to refresh.

Datagrid Wont Refresh!
OK...Im updating an Access table through an ADO data control and a datagrid on a form. My table is being updated but the datagrid will not refresh until after the next action. Immediate refresh is required for this progrm. The procedure follows...I can find NO reason why this will not refresh the datagrid.

Private Sub cmdUpdate_Click()
Dim vntButton, vntButtonIndex As Variant
Dim sngPercent As Single


On Error GoTo ErrorMsg

'Validate user input.
If Not IsNumeric(txtIncrease) Then
MsgBox ("Sorry, input must be numeric!")
With txtIncrease
.Text = " "
.SetFocus
End With
ElseIf (CInt(txtIncrease.Text)) < -100 Then
MsgBox ("Number cannot be less than -100." & vbCrLf & _
"Please try again.")
With txtIncrease
.Text = " "
.SetFocus
End With
End If

vntButton = Array(1, 2, 3) 'Array declaration

If optCategory(1).Value = True Then 'Uses the array to determine
vntButtonIndex = vntButton(0) 'which option button is chosen
ElseIf optCategory(2).Value = True Then 'and assigns the correct value
vntButtonIndex = vntButton(1) 'to the variable.
ElseIf optCategory(3).Value = True Then
vntButtonIndex = vntButton(2)
End If

'Converts the text input into a variable used as the percentage.
sngPercent = (1 + (CSng(txtIncrease.Text) / 100))

'Performs the update command and calculations on appropriate records.
mstrSQL = "UPDATE tblInventory " & _
"SET fldCost = fldCost * " & sngPercent & "" & _
" WHERE fldCategory = " & vntButtonIndex & ""

'Executes the command and refreshes the DB and grid.
mcmdCurrent.CommandText = mstrSQL
mcmdCurrent.Execute
adInventory.Recordset.Requery
adInventory.Recordset.Update
adInventory.Refresh
dgInventory.Refresh



Exit Sub

'Displays error description in message box.
ErrorMsg:
MsgBox (Err.Description & "--" & "Error Number " & Err.Number & _
vbCrLf & "Please try again.")
With txtIncrease
.Text = " "
.SetFocus
End With

End Sub

Refresh The Modifications In The Datagrid RS
The problem is the following: i first open a form(1st) where i have several datagrids, and each one has their sql comand done by code (this ones are just to see not to modify) Then you can open another form(2ond) here the first form is still load, where the only datagrid that you see contents all the records splited before in the small datagrids on the other form(1st). Here is (2nd)where the user can delete and add new records.
What i'm looking is that after the user close this form (the one with 1 datagrid and all the records)(2nd) the small one's on the other form (1st) refresh the modifications that were done before just by closing the form(2nd). I know that if i open again the forms you can see the change's but i would like that the user can see already the change's before closing the first form that was open(1st).
Some people told me that i must do that by the requery method? do you know any other way more simple?

VB 6 Datagrid Refresh Problem
I have a timing program that reads from an external source and displays the data through the DataGrid control. The grid displays columns some of which are editable and some that are not. The first column is the station ID, which I have set to locked. When a user edits one of the editable cells though, and leaves it, when the datagrid automatically refreshes, the data jumps over to the first row, first column, I.E. a supposedly uneditable column. Is there any way to keep this from happening?

P.S. If the program is closed and reopened, the first row/first column cell is returned to the correct value.

How To Refresh Textboxes According To The Datagrid??
Hi,

I have a grid (a MSHFlexGrid) and some textbox below it. Actually they are referring to the same record set. I would like to display the data in the textbox according to the current record (the one highlighting on grid). How to achieve this?

Thanks for any help here!

DataGrid Refresh Question
VB 6 Enterprise

I have attached 2 jpg files. They are snapshops of a datagrid BEFORE and AFTER the code below.

I am deleting a record based on a primary key (dbTrackLineNumber) defined as type = long.

When you look at the "BeforeDelete.jpg", column 8 (physically column 9) is the primary-key. The user selects the record and hits a DELETE button(not shown in jpg). This code is executed:

Code:
SQL = "Delete from DuplicateTracking where dbTrackLineNumber = " & CLng(dbgDuplicates.Columns(8)) & ";"
pconTracking.Execute (SQL)
dbgDuplicates.DataChanged = True
DoEvents
dbgDuplicates.Refresh
Set dbgDuplicates.DataSource = rstDT
dbgDuplicates.ReBind
DoEvents
NOTE: pcontracking = the connectionstring; dbgDuplicates = the name of the datagrid; rstDT = is the name of the DuplicateTracking recordset

After this code is completed, I have checked the "DuplicateTracking" table and the record being deleted is no longer there.

What is happening after this code is execute (see AfterDelete.jpg), the record is still in the datagrid and the datagrid has scrolled downward showing the record I am trying to delete as the first record on the screen. I can scroll up and see the records above it.

I know DataGrids have always given people a hard time but I would like to use it in this situation. Can anyone tell me how to fix the problem without re-creating the recordset. The database contains over 10000 records and it takes time to create the recordset.

Thanks,

Datagrid Does'nt Refresh After Delete
Hi there!
I'm trying to delete a row from my ACCESS database using my datagrid, so far so good.
after I click the Delete button the datagrid remains as it is and the row that was just deleted is still visible!
to see the datagrid with out that row I have to close the form and open it again! and i do'nt want that!
the code:

Quote:




Private Sub delete_Click()
Dim Flights As Database
Dim rst As Recordset
Dim path, strDEL As String

path = CurDir() & "Flights.mdb"
Set Flights = DBEngine.OpenDatabase(path)
strDEL = "delete * from private where departure='" & dep & "' and destination='" & des & "' "
Flights.Execute strDEL

DataGrid1.Refresh
End Sub




the datagrid's source is an adodc object
I have to clear that the delete proccess is working perfectly! I only have problems with the refresh!
THX in advanced

Datagrid Rebind / Refresh ???? Help
I've search though the forums and have seen other threads dealing with this topic and have tried to implement some of the suggestions I've seen but nothing seems to be working for me and I'm at my wits end.

I have a form with a data control (ADODC_Invoicing), and a datagrid (Grd_Invoicing). The datagrid is bound to the data control at design time, while the data control has none of its connection or recordsource properties set at design time.

What I want to do is to load selected columns of a table at run time and be able to change the datagrid when various other controls on the form are altered.

The code below is what runs when the form is initially opened and is intended to set the datacontrols connection properties and recordsource (as a SQL query).

However when I run the form nothing appears.


Code:
Set_Invoice_DataGrid()

frmMain.ADODC_Invoicing.ConnectionString = "DSN=NZTC_Manager"

frmMain.ADODC_Invoicing.RecordSource = "SELECT Exhibitor_Name, Auto_P, Start_Date, Annual_Payment, Monthly_Payment , January From tbl_InvoiceData"

frmMain.ADODC_Invoicing.Refresh

'connect data grid to invoicing ADODC
Set frmMain.Grd_Invoicing.DataSource = frmMain.ADODC_Invoicing

frmMain.Grd_Invoicing.ReBind

frmMain.Grd_Invoicing.Refresh

End Sub
I've tried everything I've seen and have been toiling over this form almost a month now and nothing seems to be working. I'm slowly going insane over this and any help would be greatly appreciated.

Refresh DataGrid After Query
Hi

I'm looking to add a record to a table and then refresh a datagrid at the same time. I'm using Dataenvironment. This code works fine first time round:

Zeus.qryBatch (intTicket)
Me.grdBasket.ReBind
Me.grdBasket.Refresh

Second Time round it gives me the Following error:

"Operation not allowed when Object is open"

I tried Zeus.rsqryBatch.requery but it gives me the following error SQL Server Error:

"Count Field incorrect or syntax error"


Any Ideas?

Different Between Rebing And Refresh, When Using A Datagrid
Hello

I am using a datagrid. and after l have input data. What should l used to save the changes to the database.

What is the difference between rebind and refresh.

Many thanks in advance

Steve

How To Refresh Data In A Datagrid?
i have a datagrid connected to a datadesigner.
this datagrid is updatable but not insertable for reasons which are irrelevant.
how can i refresh the datagrids data when a manual insert into the database has been done ?
(manual insert means: connection.execute ("insert into .....")
i know i could use the requery method of the whole recordset but this would mean it would set the bookmark of the recordset to the first record and this is what i want to avoid....
anyone any ideas?
thanks

Datagrid Refresh Problems
What I want do is have the datagrid display a list of records that match a certain search pattern. During the search process, the database is updated as the program ranks each record on relevance.

The datagrid needs to list the records in oreder of rank.

The procedure works fine, however the updates seem to lag behind. If I enter the search string and press search, about half the time it works, and the rest of the time it returns the results from the previous search.

I dont want to put a pause in here, as it makes it feel akward, although a 2 second pause (with doevents) does work.

Any suggestions ??

Datagrid Refresh ***RESOLVED***
I'm using a data bound datagrid with an ado data control. The SQL statement in the recordsource property of the ado data control changes, but the new data does not appear in the datagrid. I've tried using ReBind, Refresh, ClearFields, HoldFields on the datagrid control, but I can't seem to get the new records to appear each time.... Can anyone help.....?
Thanks in advance

Datagrid Update-refresh
I know there's lot of tread about the subject, but my case is a bit different though: when i update a row in a datagrid, then in the "afterupdate" event i do a adodc1.refresh and a datagrid.refresh, and then the application stops responding.......

I've downloaded true db grid (version 7.0) from apex (now something software), and it does the same.

All the other tricks (unload reload of the form) did the same

here is my system configuration:

win2000 sp1
vb6 sp5
ado 2.5
access 2000

Any idea ?

i know datagrid is a piece of sh*** but i had to do a job very fast (should have taken less time with handmade controls)

Refresh DataGrid On Different Form
If I add a new recordset on one form, can I refresh a datagrid on another form with a datasource pointing to the same recordset. I tried requerying, and refreshing the recordset but it still won't do it. Any help would be appreciated, thanks in advance.

DataGrid Runtime Refresh. Help.
Hi all,

I have a DataGrid with ADODC on a form. Connecting to a SQL server database.

I also have a combobox containing the table names that the user can select.

What I want to do is form opens with blank DataGrid. User selects a table from the combobox, and it displays the table contect in the DataGrid.

This is my code from the Click event of the combobox:

------------------------
Private Sub cmb_dbtable_Click()

Select Case cmb_dbtable.Text
Case "Clients"
Data1.RecordSource = "Clients"
Case "Bills"
Data1.RecordSource = "Bills"
End Select

Set DataGrid_dbtable.DataSource = Data1
DataGrid_dbtable.ReBind

End Sub
-------------------------

Ok. Form opens with blank DataGrid. User selects a table from combobox for the FIRST time. Connects to DB, and table is displayed in DataGrid. THIS WORKS FINE only on the FIRST time.

After the DataGrid is populated, the next time user selects another table, the DataGrid does not refresh. It just stays with whatever is already in there. It seems that ReBind doesn't do anything.

Please post clues, hints, or anything you can think of. I really appreciate it. Thank you.

Refresh DATAGRID (SPECIFIC)
Hi!! i try to refresh the datagrid where my data from database are!! i need to refresh only that record where i made the changes, not all datagrid, becouse then the ACTIVE record again is first, but i need that the Active record is the same after refreshing datagrid!!

Unable To Refresh Datagrid?
hi,
unable to refresh data grid at runtime

Application is in
   VB 6, ADO 2.0
   Event is double click List1
   Database : Access

Flow -  select a Number (from datacombo1.text) and display the connected transaction(table) in datagrid.

number is selected from datacombo1.text(connected to ADODC1.recordset) and connected transaction record is displayed in datagrid.

To Add, double Click - list box and Item from list box are added to transaction table.

For first top item selected from datacombo1.text, it adds properly the connected item selected from list box also displays it correctly in datagrid i.e. just below the existing transaction of the datagrid.

Everything is fine on adding the record from list box, for the first top item selected from datacombo1.text and also displays correctly in datagrid.


Error:
when adding new transaction for the second or third or ..... items selected from datacombo1.text.

It correctly adds the new record in the transaction table(selected from list box), only thing is, does not display record it in datagrid with new record added to transaction table at runtime.
(what it shows in the datagrid is the transaction of the first item of datacombo1.text)

Only after closing the form and restarting the form it displays the record correctly.


Adodc1.recordset
Most Variables are declared public

shape {select  COID,No,IDate,TDate,Rate, GrossAmt from Master order by No} as ParentCMD
APPEND ({select t_no as no,t_sno,t_itUnit,t_qty,t_rate,t_amt as Amt from Tran order by t_sno,t_hno } as CHILDCMD
RELATE No to no) as childcmd

public sub  dGrid
    Adodc1.Refresh
    Adodc1.Recordset.Requery
    Set DataGrid1.DataSource = Adodc1.Recordset("ChildCMD").UnderlyingValue
end sub


private sub list1_dblClick
    Dim i As Integer
    Dim j As Integer
    
    Dim sqlSt As String

    Dim lth As Integer
    Dim vlth As Integer
        
                
        For i = 0 To List1.ListCount - 1
            If List1.Selected(i) = True Then
                
                vlth = 1
                lth = Len(List1.List(i))
                
                Do While lth <> 0
                   If MID(List1.List(i), vlth, 1) = "/" Then
                        Exit Do
                   Else
                      vt_itid = Trim(MID(List1.List(i), 1, vlth))
                      vlth = vlth + 1
                      Debug.Print Text2.Text
                   End If
                   lth = lth - 1
                Loop

                vlth = Len(Text2.Text)
                
                For j = 0 To List2.ListCount - 1
                     If Trim(MID(List2.List(j), 1, vlth)) = Text2.Text Then
                            vsno = vsno + 1
                            vTextData = List2.List(j)
                            vlthText = Len(vTextData)
                            
        ' to check whether the recordset is
                ' transferred properly
                            Debug.Print "vTextData " & vTextData  
                                
                ' for transferring value from vTextData
                ' to each variable
             Call trfValue
                        vTotal = vRate * vMMnt

'using an sqlst for inserting records

                cn.Execute (sqlSt)
                            
                            Exit For
                            
                     End If
                     
                Next
                                  
            End If
            
          call Dgrid
            Call dispColumn   ' - displays data in formatted datagrid
        Next
        
    End Select
end sub

Thanks,

Lad

Refresh VB 6 Datagrid After Deleting Row
Hello everyone,

I'm new to vb and this forum. I need help from anyone please. I've looked through the posting but I cannot find an answer for my problem. My problem is refreshing a datagrid after I delete a row. Below is the code that I am using. I have tried various suggestions but nothing seems to work.

Again any help would be appreciated. Thanks in advance.

UTDEL

Private Sub cmdDelete_Click()
Dim pstrSql As String

Dim pstrPartNum As String
pstrPartNum = InputBox("Enter part number to delete", "Exercise 1 - Delete Part Number")
If StrPtr(pstrPartNum) = 0 Then
Exit Sub
End If

If Val(pstrPartNum) Then
pstrSql = "DELETE * FROM tblInventory " & _
" WHERE fldPartNum = " & pstrPartNum
' MsgBox pstrSql
mcmdCurrent.CommandText = pstrSql
mcmdCurrent.Execute

pstrSql = "SELECT * FROM tblInventory " & _
"WHERE fldCategory = " & mstrCategory
adInventory.RecordSource = pstrSql
adInventory.Refresh
dgInventory.Refresh
MsgBox "Part Number " & pstrPartNum & " deleted", vbInformation + vbOKOnly, "Exercise 1"

Else
MsgBox "Must enter a valid part number", vbCritical + vbOKOnly, _
"Invalid Part Number"
End If
End Sub

How Do I Refresh A Datagrid Or A Form?
I'm writing a simple query parser that will take SQL statments for Access, instead of having to use the Access UI.

I make the changes by clicking on a button that will bring up an InputBox and I'll type in the SQL statement there. I'd like the form (or datagrid) to refresh after I've clicked the 'OK' button on the InputBox.

I've used the obvious refresh method (Both Datagrid.Refresh and Form.Refresh), but it doesn't work. What is the correct method of doing it?

Much appreciation for any help.

Datagrid Refresh Problem
hi, i m trying to update data by taking another frame on the same form and then by update query for the selected row on the datagrid,, now the problem is that when i update my grid from this frame and return back to grid i do not get the updated data,, what should i do... pls help me..

Datagrid Wont Refresh!
OK...I'm using an ADO datacontrol and a datagrid to update Access database tables. My table is being updated, but the datagrid does not refresh the data until after the next action. I've tried everything I know...the procedure is below:

Private Sub cmdUpdate_Click()
Dim vntButton, vntButtonIndex As Variant
Dim sngPercent As Single
Dim rsInventory As Recordset

'On Error GoTo ErrorMsg

'Validate user input.
If Not IsNumeric(txtIncrease) Then
MsgBox ("Sorry, input must be numeric!")
With txtIncrease
.Text = " "
.SetFocus
End With
ElseIf (CInt(txtIncrease.Text)) &lt; -100 Then
MsgBox ("Number cannot be less than -100." & vbCrLf & _
"Please try again.")
With txtIncrease
.Text = " "
.SetFocus
End With
End If

vntButton = Array(1, 2, 3) 'Array declaration

If optCategory(1).Value = True Then 'Uses the array to determine
vntButtonIndex = vntButton(0) 'which option button is chosen
ElseIf optCategory(2).Value = True Then 'and assigns the correct value
vntButtonIndex = vntButton(1) 'to the variable.
ElseIf optCategory(3).Value = True Then
vntButtonIndex = vntButton(2)
End If

'Converts the text input into a variable used as the percentage.
sngPercent = (1 + (CSng(txtIncrease.Text) / 100))

'Performs the update command and calculations on appropriate records.
mstrSQL = "UPDATE tblInventory " & _
"SET fldCost = fldCost * " & sngPercent & "" & _
" WHERE fldCategory = " & vntButtonIndex & ""

'Executes the command and refreshes the DB and grid.
mcmdCurrent.CommandText = mstrSQL
mcmdCurrent.Execute
adInventory.Recordset.Requery
adInventory.Recordset.Update
adInventory.Refresh
dgInventory.Refresh



Exit Sub

'Displays error description in message box.
ErrorMsg:
MsgBox (Err.Description & "--" & "Error Number " & Err.Number & _
vbCrLf & "Please try again.")
With txtIncrease
.Text = " "
.SetFocus
End With

End Sub

URL Refresh In Combo Box Or Text Box
in my web browser i have a text box at the top but i cant get it to show the url of the current web page that i am viewing. anybody have any code or ideas to help???

Combo Boxes Get Cut Off/won't Refresh
I have two forms, let's call them A and B. Form A is the main program and has a section that contains 4 combo boxes. Under these combo boxes is a button that will let you add items to the combo box lists (All 4 contain the same list of items). When you click the button, Form B pops up with a list of what is currently in the combo box drop down lists.

So you type in your new entry on Form B and click "Add". This writes the new entry to a database and then calls a function on Form A that clears the combo box lists and refills them from the database. Then Form B unloads itself.

If any part of Form B is over any of the 4 combo boxes when it unloads, then the combo boxes are cut off exactly where the form was. You can still click the drop down arrow (if you can see it) and the list is there, you just can't see the entry box. If you change screens or minimize and come back the combo boxes are back.

I have tried adding some refresh lines to the function, but they don't help. Here is the combo box filling function:


Code:
Public Sub fillAssetSources()
Dim select1 As String
Dim i As Integer

For i = 0 To Combo2(12).ListCount - 1
Combo2(12).RemoveItem (0)
Combo2(14).RemoveItem (0)
Combo2(16).RemoveItem (0)
Combo2(18).RemoveItem (0)
Next i

cn.Open strConnect

select1 = "select * from assetSources order by source"
rs.Open select1, cn, adOpenKeyset, adLockReadOnly

While rs.EOF = False
Combo2(12).AddItem (Trim(rs!Source))
Combo2(14).AddItem (Trim(rs!Source))
Combo2(16).AddItem (Trim(rs!Source))
Combo2(18).AddItem (Trim(rs!Source))

rs.MoveNext
Wend

rs.Close
cn.Close
End Sub

Any suggestions?

/<evin

Refresh Form When Combo Box Is Used
I am seeking your help to resolve my problem, I have a program for my shares stock, when program is running, every control in the form is exposed fine and normal, see below:

But when I select any option from the combo box drop menu, and I release mouse button, the program will work as expected and display the out put data in the list as per my selection criteria, however, shadow of the combo box when it was dropped down will be remained in the screen and I have to minimize it and maximize it again in order to clear it out, pleas see below:

This problem occurs also in some cases when other program comes over my program
I set property (AutoRedraw) to true, but problem persist.
Appreciate your advice
Thanks

Combo Box Refresh Question
I have what I am sure is a simple question that I cannot seem to figure out. I have a combo box on a form with a command button next to it. Example: the combo box will list employees and the command button will open another form so that a new employee (not listed in the combo box) can be added.

The problem is, when the form is closed the new employee just added does not show up in the combo box. I have tried everything I have found listed in the post here but nothing seems to work.

I have tried the "click" event to repopulate the combo box (I even tried to close the connection to the table and reopen it again and then repopulate the combo box). The new entry will NOT show up on the combo box list and I am lost ... I would be thankful for any assistance...

BTW, if I choose one of the existing entries and save it ( .update) when the combo box is clicked the next time - the new entry shows up.

Thanks,

Copyright © 2005-08 www.BigResource.com, All rights reserved