Solved

VB 6 Data grid control

Posted on 2006-07-18
2
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Make the most of your online learning experience.
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…
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…

631 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