Solved

VB 6 Data grid control

Posted on 2006-07-18
2
283 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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

13 Experts available now in Live!

Get 1:1 Help Now