Solved

VB 6 Data grid control

Posted on 2006-07-18
2
286 Views
Last Modified: 2010-04-17
Sir, I am using data grid in my application, which have three columns.

1.     Job #
2.     Balance Amount
3.     Received Amount

The one and two columns are locked, in other words user can not enter data in column one and two however three is open for user for entering received amount against of balance.

For example we have twenty jobs/rows on grid which payment we have not received yet. However we received payment only against four job then user go on respective job # and enter data in column received amount what ever he received. After updating four jobs in data grid against which he received payment user click save button and on click I want to run a loop to update respective four rows against which we have received amount in database.

Please help how it possible

Rgds.
Mehram
0
Comment
Question by:Mehram
2 Comments
 
LVL 7

Accepted Solution

by:
assyst earned 500 total points
ID: 17131222
I believe you are asking for the code to update the data from datagrid to database

We can save the data row by row from the datagrid. we have to use a loop for doing this.

You have to create a recordset for this and

Private sub cmdSave_Click

Dim recSave as new ADODB.recordset
irecSave.open "Select * From <table name> where null=null", <connection object>, <lock type>

rec.movefirst
while rec.eof = false
    if val(rec.fields("Received Amount")) <> 0
       recSave.addnew
           recSave.Fields("Job #") = rec.Fields("Job #")
           recSave.Fields("Balance Amount") = rec.Fields("Balance Amount")
           recSave.Fields("Received Amount") = rec.Fields("Received Amount")
       recSave.update
    end if
 rec.movenext
wend
recSave.Close
end sub
0
 

Expert Comment

by:misbah_ra
ID: 17132403
We can save the data row by row from the datagrid. we have to use a loop for doing this.

You have to create a recordset for this and

Private sub cmdSave_Click

Dim recSave as new ADODB.recordset
irecSave.open "Select * From <table name> where null=null", <connection object>, <lock type>

rec.movefirst
while rec.eof = false
    if val(rec.fields("Received Amount")) <> 0
       recSave.addnew
           recSave.Fields("Job #") = rec.Fields("Job #")
           recSave.Fields("Balance Amount") = rec.Fields("Balance Amount")
           recSave.Fields("Received Amount") = rec.Fields("Received Amount")
       recSave.update
    end if
 rec.movenext
wend
recSave.Close
end sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
My 2003 Land Rover discovery 2 key for code for car alarm 7 106
word0 challenge 4 64
eclipse package explorer vs project explorer view 2 72
C Programming - If Statement 8 72
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now