473,382 Members | 1,302 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,382 software developers and data experts.

Deleting Row from data file from MSFlexGrid

63
Hey, I would like to delete a row of data from my data file, though using an MSFlexGrid. I can currently delete any selected row, though it only deletes a row from the Grid, and not the entry itself. Please Help
Feb 26 '08 #1
3 2577
VBWheaties
145 100+
Hey, I would like to delete a row of data from my data file, though using an MSFlexGrid. I can currently delete any selected row, though it only deletes a row from the Grid, and not the entry itself. Please Help
There are several ways to do this.
I would do it manually by sending a DELETE query to the datasource.
Then, refreshing the recordset the grid is based on.
But, others may suggest otherwise.
Feb 26 '08 #2
MiziaQ
63
There are several ways to do this.
I would do it manually by sending a DELETE query to the datasource.
Then, refreshing the recordset the grid is based on.
But, others may suggest otherwise.
How can I do that ? Could you give a code example please.
Thanks
Feb 26 '08 #3
VBWheaties
145 100+
How can I do that ? Could you give a code example please.
Thanks
Ok, but I will be making many assumptions about your data strategy.

Assuming each record on the grid has a primary key (or something to uniquely identifiy that record),
when the user chooses to delete THAT record, send the records primary key to this function:

Expand|Select|Wrap|Line Numbers
  1. Public Sub DeleteRecord(PrimaryKeyValue as String)
  2.    Dim sSql As String 
  3.    sSql = "DELETE FROM myTable WHERE PrimaryKeyField = '" & PrimaryKeyValue & "'"
  4.    adoCon1.Execute sSql 
  5. End Sub 
  6.  
Then, refresh grid assuming it was binded to a ADODB recordset object:

Expand|Select|Wrap|Line Numbers
  1. Public Sub RefreshGrid()
  2.    Dim rs As Adodb.Recordset 
  3.    Set rs = fgData.DataSource
  4.    rs.Requery 
  5.    Set fgData.DataSource = rs
  6. End Sub 
  7.  
The assumptions I made were:
1. You have a global adodb.connection object called adoCon1
2. adoCon1 is established and ready to do work.
3. Your grid is bound to an ADODB recordset object.

Hopefully, your actual setup is not much different. But if it is, pay more attention to the concept of deleting the record using primary key and resetting your grid from the datasource.
Feb 26 '08 #4

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

Similar topics

5
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the...
0
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
2
by: Jyoti Khalap | last post by:
Hi, I am new to Visual Basics. Can anybody help me out to get the data in MSFlexGrid to be written to word file or a text file I have succesfully ran my visual Basic form to get the output in...
2
smartchap
by: smartchap | last post by:
In VB6 in a form there are 10 labels and associated 10 textboxes and 2 MSFlexGrids. There are 5 columns in the first MSFGrid and 7 in the second MSFGrid. There are 3 rows in the first grid and 4 in...
1
by: MiziaQ | last post by:
Hey, how can I delete an entire row from an MSFlexGrid table, and how can I allow the user to only select one row (i.e. not allow multiselection of rows ?) Thanks in advance, MiziaQ
1
by: MiziaQ | last post by:
How can I delete a row of data from a data/text file in vb6 ? I am using an MSFlexGrid, so the user can select which row is to be deleted. Thanks in advance, MiziaQ
4
by: MiziaQ | last post by:
Hey, I'm using the following code to write entries to a data file and then read them in an msflexgrid. I now would like to add code under a delete button to use the table(grid) to delete rows from...
0
by: MiziaQ | last post by:
Hey, I'm using the following code to filter an msflexgrid to only display rows with the entry "East Cork" in the 8th column. The table has many more entries, so, when I run the application, many...
2
by: JuAn2226 | last post by:
hi,I got few question here. Hope some one can me. plz help me i running out of time 1. how to make my msflexgrid to display data for every 5 min(especially the number car and average speed. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.