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




Deleted Selected Records In Datagrid In Vb6


I have a number of records in datagrid1 in vb6, i want to delete selected records from datagrid. suppose user selects row no. 1, 4, 10, 15 and when he clicks delete button which is there in form, the selected row (records) should be deleted.

Please help me to do this in vb6. i will wait on nitin@alsahel1.com

Thanks & regards,

Nitin




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Copy Selected Records From DataGrid To Clipboard
1. How to on multiselection records in datagrid? because when i click on first record and then on second two record then first record lost selection
2. How to copy only selected records from datagrid to clipboard?

i write something like this

Private Sub DataGrid2_Click()
Dim abc As String

abc = ""

Do While Not rer.EOF
        abc = abc & " " & rer.Fields("FE") & " " & rer.Fields("TYP") & " " & rer.Fields("ZIARNO")
rer.MoveNext

Loop


Clipboard.Clear
Clipboard.SetText (abc)

End Sub

and this working but how to select more than 1 record? I use CTRL and select multi records but then this program not working

Deleted A Selected Table From A Listview?
Hi guys.

I have a listview control and I figured out how to keep the rows highlighted for selecting a listitem row. I can delete entries from the control but the entry that deletes isn't the one that is highlighted for deletion.

Here's what I have for code so far:

Code:
Private Sub cmdDelete_Click()
Dim I As Integer
Dim ListIndex As Integer
On Error Resume Next

dbTable.MoveFirst


Do Until I = Val(txtID)
    DoEvents
    I = (dbTable!id)
  If I <> Val(txtID) And lstContacts.SelectedItem Then dbTable.MoveNext
Loop

If lstContacts.ListItems.Count = 0 Then
  MsgBox "There are no entries to delete from the database.", _
  vbOKOnly + vbInformation, "Database is empty"
  Exit Sub
End If

'In case user should change their mind.
If MsgBox("Are you sure you want to delete this contact?", _
  vbYesNo + vbQuestion, "Delete contact?") = vbYes Then
    If lstContacts.SelectedItem.Text = lstContacts.SelectedItem Then
      txtFirstName.Text = ""
      txtLastName.Text = ""
      txtAge.Text = ""
      txtEmail.Text = ""
      txtPhoneNumber.Text = ""
      txtAddress.Text = ""
      txtLocation = ""
      txtComments.Text = ""
      dbTable.Delete
    Else
      Exit Sub
   End If
End If

'This lists all as new
cmdListAll_Click

End Sub


This code deletes the topmost item from the listview.

I have tried using the "selecteditem" options for listview in "if" statements for trying to delete certain entries but can't figure it out. If anyone knows what I am doing wrong that would be great. Thanks

RJ

Deleted Records
Hi,
Let's say i have some form with four fields ( the key field is dial number ) and i am using static curser , now the first user open the form and made some query on the dial number field ( > 5% ) he retrived 556 , 557 ,558
now the second user open the same form and delete 556.
now the first user trying to modify some field on the same record ( 556 ) . in that case or any other case of changing some field
of deleted record will immidiatly accompany with error an message
do you know how to do it ?

Storing Deleted Records
I have an Access 2000 database and I need to be able to save records that have been deleted from the main table. The user does not want to see the records they deleted from their input form, but they would like to have the data in a backup table so they can use it for historical data.

The user currently adds, deletes records by using the standard MS access "New Record", "Delete Record" buttons from the toolbar menu.

If anyone knows how this can be done please let me know.

Deleted Records In Ado Recordset
I am using a client side ado recordset to maintain a queue in my application. This recordset is filtered between each record addition or deletion. The problem I am encountering is that the deletions from the recordset don't actually physically remove the records and this is making each filter method slower and slower. It is waiting for an update to a datasource to clear the deleted records but that is never going to happen because there is no datasource.

Does anyone know how to clear the deleted records from the recordset without having a datasource to synchronise with?

Some Records Get Deleted(VB6.0/ACCESS200)
Hi, I developed a program for my client using VB6.0 and MS Acess 2000 as the database. I use Microsoft.Jet.OLEDB.4.0 as provider. The Databased is being access via network.

My problem started when my client reported to me that some of the records they've encoded gets deleted at any given time. It happened several times already that a few records they encoded were lost, sometimes after closing and reopening the program or sometimes the records disappear the following day..We've been trying to solve this problem for a week now and we havent got a solution.

Last friday, weve double check the database and all the transactions are there but when we check it today some records at the master table including all the child records weredeleted. It doesnt happen on a regular basis so it's really hard to find solution.What could be causing this?

Get The Number Of Deleted Records
Is possible to get the number of the deleted records (in an Access db) when I run a typical execute command?(without running a select query first)


Code:

sqlCmd = "delete from mytable where id = 5 "
Set cmd = New ADODB.Command
With cmd
Set .ActiveConnection = myConn
.CommandText = sqlCmd
.Execute
End With
Set cmd = Nothing

Deleting Records Or Marking Them As Deleted?
Hi all,

I am working on a database project that rarely needs records to be deleted. Lets say maybe 2 or 3 records out of 150 records may need Deletion in a day.

I am using Access database for this project. And as I am reading problems attached to access database in forums ( things such as compacting, repairing etc.. ), I got the Idea that "not deleting the records but marking them as deleted" may increase Access Database integrity.

I just wonder if it is a good Idea or I am talking non sense?

Thanks All.

Shifting Records Numbers After 1 Is Deleted
Is there a way to do this - If I had a database with 25 records when I delete a record say Number 20 all the files that follow move down a number so I now have records 1 -24 and not 1-19 and 21-25???

The delete code I have at the minute is:

[code]
Private Sub CmdDelete_Click()
If MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion, "Delete?") = vbNo Then 'check if you really want to delete this record
Exit Sub 'exit the command
Else
If Not (rs.BOF = True Or rs.EOF = True) Then
rs.Delete 'delete the current record
If Not (rs.BOF = True Or rs.EOF = True) Then
rs.MoveNext 'move next
If rs.EOF Then rs.MoveLast
fillfields
End If
End If
End If
End Sub
[code]

p.s How do I do that thing like [code] so the code is set back in a box?

Either BOF Or EOF Is True Or The Current Records Has Been Deleted...PLEASE HELP!!
I have this query, that works fine, I have tested it in MS Access & returns the correct Field:

VB Code:
strSQLquery = "Select AmountCharged From Invoice WHERE [PIN]= '" & frmWelcome.txtPatID.Text _    & "'" & "AND [VisitDate]= '" & strDATECURTIME & "'" & "AND [STATUS]='FALSE' Order by [VisitDate] Desc"    Rs.Open strSQLquery, Cn    Label2.Caption = Rs!AmountCharged


It gives this error:

Quote:





Either BOF OR EOF is True, or the current record has been deleted. Requested operation required a Current Record






Although I have 2 records in the Table I'm querying...Any ideaS?

Access Db - Recover Deleted Records?
Is this at all possible? I mean, what's in all the wasted space that disappears when you do a compact?

Removing Deleted Records In DBase IV?
Anyone out there who knows how one can remove deleted records from a dBase IV table?

Compacting it perhaps and how?

I´m using ADO to add/import records to a dBase IV database used by a special application(CITECT). Since I run my import utility a number of times the database(actually the table file *.dbf) is growing with undeleted records and this is of course not desirable.
For the moment i have been using two different Connectionstring,(both works so far but maybe I need something else in order to compact the files)

Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:PROGRAMCONTROLCITECTUSERAKADEMISKA;

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:PROGRAMCONTROLCITECTUSERAKADEMISKA;Extended Properties=dBASE IV;


Would appreciate if anyone can help out
/Ramses

Remove Deleted Records Out Of Foxpro Database.
Hi,
Pls show me the code to delete completely a record out of the Foxpro table.
Thank you very much.

How To Access The Deleted Records From VFoxpro Table
Hi,

I have a table in Visual Fox, so I connected with Vfoxpro table from visual basic using ODBC. But problem is that how can I access the deleted/flagged records from table using VB.

Thanks for solving the problem

Do People DELETE Records From The DB, Or Just Flag Them As Deleted?
Say a Job record has a Job type ID associated with it...
Now, what would people normally do if an administrator tried to delete a JobType that was in use by a job?
Would u flag it as deleted so that it would show in drop downs or would you just raise an erro saying you cannot delete it???

I have never been able to get my head around this...

Woka

Datagrid - Cell Contents Deleted
I'm using a Datagrid (Microsoft DataGrid Control 6.0 (SP6)) bound to an ADO data control as a quick and easy way to edit some data in an Access table. As soon as I load my form (an MDI child) the first cell (top left corner) in the grid is cleared and the corresponding data in the table is deleted. It's as if the text in the cell has been highlighted (selected) and the delete key pressed. The remaining cells are fine and I can navigate the grid with the TAB and arrow keys and change data just like you'd expect. Why am I losing the contents of the first cell at startup?

Thanks for your help.

Paul.

Please What Kind Of Control That Displays Multiple Records And Has A Check Boxes So That I Can Check The Selected Records And Save Them In VB6.0?
Please what kind of control that displays multiple records and has a check boxes so that I can check the selected records and save them in VB6.0? ...?

Datagrid Maximum Records (Overflow When Records Reached 32,768)
A blessed day to all of you.

The program received an error when records reached 32,768. It was only working until 32,767.

I just thought the problem was on Datagrid and not on MS Access.

Please kindly help.

Best Regards

ADO -Add Selected Records In VB6
Hi,

If I already have an ADO connection to a database but want to know how many records have "1" in the TAG field how can you query such a database in VB6. A normal SQL query would be something like: I think...

SELECT Sum(Field1) as total_Selected, Field1 FROM myTable WHERE TAG = "1" GROUP BY Field1

Thanks for any help

Add Selected Records To Mshflexgrid
I have a database with several records which I am trying to display in
mshflexgrid. I want to display only a few selected records. How do I
code this?
--
Chilangisha B Changwe
email@removed

--
http://www.fastmail.fm - Accessible with your email software
or over the web

Print Only The Selected Records
Hi,
I have a Vb6 project whith DataEnvironment and a DataReport. I whant to print only a record that I select from a text box instead of all the records.

How can I do this ? For showing the report I use this line:
DataReport.show

Thanks in advance.
ppontes

How To Check If Selected Records
i have a question

how to check if user selected any records in datagrid?

DataGrid1..... ?

Randomlly Selected Records
I have a Problem to select randomly Records from a table which sould be unique and copy selected records into another table.

So please favour me for such program.

Thanx

Adding Selected Records Values
Hi,
I'm trying to add field values together from different record.
Example.

My Access database have a field called "Value" and another field called "Amount".

All i want is. If the Value = "On" then add "Amount" to the total and it goes through the whole Table adding the "Amount"s which have been set to On.

I was given this code but I dont understand SQL in VBA very much.

"SELECT Sum(myField) as total_Amt, Field1 FROM myTable GROUP BY Field1"

How To Print The Selected Records Using Code
How to print the Checkbx Selected List

Thanks in Advance

Don't Retrieve Selected Records From Database
I devoloped an aplication using visual basic 6.0 and crystal report 8.5. The aplication work correctly in my machine that uses windows 98. I installed the aplication in a lot of machines that have windows 2000. The problem is that the reports sometimes doesn’t show all records. For example I run the program and this program doesn’t show all records but two minutes later it does.
Now I will show a cycle that I used to form a file that I uses to print the information. The problem is that work sometimes. I think is that by some problem the program doesn’t retrieve all records in the select.
Please help me.
example:
‘ delete all records of user that is working.
sql01 = Empty
sql01 = "delete from delbalances where fausua='" & usuarioprocesando & "'"
based1.Execute sql01, dbSQLPassThrough

‘ select only the records of the invoice choosed.
sql08 = "select * from delfact01 where facont='" & smt24501.wscodi & "' order by fadeud,mid$(fafeem,7,4),mid$(fafeem,4,2),mid$(fafeem,1,2),fanufa"
Set recordset8 = based1.OpenRecordset(sql08, dbOpenSnapshot, dbSQLPassThrough)
Do While Not recordset8.EOF
Insert ………
'execute insert to file
based1.Execute sql02, dbSQLPassThrough
recordset8.MoveNext
Loop

‘ The crystal select the records of the user that is working.

Delete Records From The Selected In List
hi everyone,
can you show me what is the syntax of deleting records in a listbox..
i can't figure it out..

what properties i'm going to use in a list..
tanx everyone..
have a nice day....

How To Print The Selected(more Than One Record) Db Records
hi,

I have created few records in db grid,
How to pass my selected records in the db grid box for the print preview as well as for the printing the selected records,

thanking you in advance

with Regards,
Girish

Printing The Selected Records In Db Grid
hi,

I have created few records in db grid,
How to pass my selected records in the db grid box for the print preview as well as for the printing the selected records,

thanking you in advance

with Regards,
Girish

Displaying Selected Records In Data Reports
Hi all
I am using data reports with out data environment.Here i am displaying the report using a table. But i am not able to display the selected records.
For e.g. A report displays Student id, Name and result.
But i want to display the results of only the passed students.can anyone please tell me How i do this?


I have used the following code:


VB Code:
Private Sub DataReport_Initialize()'Procedure to connect databaseconnection strSQL = "SELECT * from tblstudent"Set rs = New ADODB.Recordsetrs.Open strSQL, cn, adOpenDynamic, adLockOptimisticSet DataReport1.DataSource = rsEnd Sub

HOw Do You Print Selected Listview Records To Printer ??
Simple one really but can i find a subject on the web that covers this?? nope.

If i have selected (highlighted) multiple records in a populated listview, how to i then print these recrods in thier entirety to a printer??

Thanks for your time

How To Display Selected Records In Crystal Report
hello...

i have a prb ... is regarding to display crystal report....means... how to get the crystal report display the selected records??
ex...
i have these Stocks
A001,A002,A003,A004, A005
i only select the A002, A003 and A004 to be display
and this is my code...
my database name is Inven.mdb


thanks
swiss

********************************************************
Private Sub cmdPrint_Click()
Dim sCondition, sTemp As String

sCondition = ""
sTemp = ""

mOK = True

If optSpecificStockCode.Value = True Then
sTemp = ("{stocktake.StockCode} >= " & cbStockCodeFrom.Text & _
" and {stocktake.StockCode} >= " & cbStockCodeTo.Text & "")
If sCondition = "" Then
sCondition = sTemp
Else
sCondition = sCondition & " and " & sTemp
End If
End If

If optPreview.Value = True Then
mDestination = crptToWindow
Else
mDestination = crptToPrinter
End If

Debug.Print "f=" & sCondition
With rpt
.Reset
.DataFiles(0) = (App.Path & "Inven.mdb")
.ReportFileName = (App.Path & "
ptst.rpt")
.WindowTitle = "Stock Take Report"
.WindowState = crptMaximized
.WindowShowRefreshBtn = True
.SelectionFormula = sCondition
.Destination = ToDestination
If .PrintReport() <> 0 Then
MsgBox "Error #: " & .LastErrorNumber & vbCrLf & .LastErrorString
End If
End With
End Sub
**********************************************

Displaying Selected Records In Data Reports
Hi all
I am using data reports with out data environment.Here i am displaying the report using a table. But i am not able to display the selected records.
For e.g. A report displays Student id, Name and result.
i have to display the results of all the students and highlight the records with the results 'fail' in red.
I tried to do this using an if statement


visual basic code:
If Datareport1.Sections("Section2").Controls("Text1").Text = "Fail" then
text1.forecolor=vbred
end if


But it is giving an error Text1 not found.
Please tell me how to do this?

Component To Display Records And Cause Events When Selected?&#191;?&#191;
Hi,
can anyone recommend a component that will allow me to fill it with database records, name the columns and allow a record/row to be hightlighted/selected and will cause an event when a row is double clicked, have been looking at datagrid but it looks really complicated from the ms online docs.
Any help would be great.
Thanks
Williery(total novice)

How To Display Selected (between Two Dates) Records In Crystal Report.
Hello Sir,

I am new to crystal report section.

I want to know how to display selected (between two dates) records in crystal report.

e.g.
If user wants to print records between two selected dates (dates selected by DTPicker1 component)

I tried several times to solve the problem. But in crystal report only few fields are displaying.

So please give the suggestion step by step.

Software used:
Front End: VB5
Back End: MS Access 97
Crystal Report: 4.6

Which Row Is Selected In DataGrid...
How can you tell which row is selected in a datagrid?
It would be good if this row had a number like in an index or something...


Also,
How can I use a datagrid to edit the information in my recordsource? I have AllowUpdate set to true, but I just don't see any update method for the control...

thanks so much,
squirrelly1

Selected Row In Datagrid
I want to write a code in rowHeader(ie.. when clicking on a particular row ) event of datagrid in vb.net.
how to raise this event in vb.net

Datagrid Selected
I have 2 datagrid in a form and i want to know which datagrid is selected when i click a command button it will identify which datagrid is selected.

Thanks.

Datagrid Row To Be Selected
Hi,

I'm currently using data environment in populating my datagrid.

Each row contains ID, Name, Class and Description columns

I have a textbox which i enter the ID to search.

How can the particular row in the datagrid being highlighted once i enter the ID into the textbox?

Thanks


Roy

Detecting IF A Row Is Selected In A Datagrid?
Using VB 6.0, is there any way to determine if a row has been selected? If the user does not select a row (or hasn't as of yet), the arrow on the right side is, by default, at the first row in the datagrid.

What I'd like to do is make that NOT the default. So, if a user accidentally hits a command button (like to delete the selected row), it won't happen unless the user has actually selected a row.

How would I go about doing this?

Thanks in advance for any help.

DTFan

Delete The Selected Row From A DataGrid
How can I remove the selected row from a DataGrid control without removing from the asociated recordset.

Regards,
fazek

Selected Field On Datagrid
Well the below code will populate all the fields after a search from SQL statement.

I want SELECTED fields to be display instead of all the fields.For example in the table i have 20 fields but i want to display 5 fields in datagrid1. How does the code look like?


VB Code:
oRs.Open SQL, oConn, adOpenStatic, adLockPessimistic, adAsyncFetchSet DataGrid1.DataSource = oRs


2nd question.
Once the record displayed in datagrid1.
Highlight the record
There is a button where i can click on the higlighted record.
All 10 fields will display in form2
and another 10 field display form1

How to do that?

Selected Position On DataGrid
Hi all

Now I am trying to get selected position where user clicks on DataGrid.
My test code is as follows.

Private Sub dgTrouble_Click()

    Debug.Print "Row :", CStr(dgTrouble.Row)
    Debug.Print "Col :", CStr(dgTrouble.Col)
    
End Sub

When I clicked certain cell on DataGrid for the first time,
I got a position data .
Then I clicked same cell , I got different position data.
But after this click, I got same position data at this cell.

I want to get same position data at first click.

Please give me some advices for resolving above problem.

 






Get A Field Value From Selected Datagrid Row
Hi

I've not coded in VB6 for quite some time am having  trouble and could use some help. I'll keep this short.

I have a datagrid populated with a recordset. If a user clicked somewhere on row 5 how could I get the value of say field 3 from row 5?

I would appreciate any help that anyone could lend.

Thanks

Hot To Delete Selected Row I Datagrid?
please help give me simple code

Datagrid Selected Row Plz Heeeeelp :(((
I use VB 6.0 and MS access

how can i get the selected row number in datagrid
and how can i set the selected row (ex. datagrid.selected row=5 )

Best regards....

How Can I Show The Selected Row In Datagrid
hello
i want to show current row which is the result of my query in datagrid
how can i do ?
In MSDN it is written "The data in the current row can be accessed using the Bookmark property"
ok it works but i want to set datagrid like datagrid1.bookmark =i but it doesn't work
also datagrid1.row is not the property that i want to use .

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