My VB6 code reads XML file
loads into MSFLEXIGRID
loops through each record, if I see a break point,
does not add data in sql table except one record why it is happening does not know. does not throw any error.
I'm appending my code below:
Private Sub cmdPrint_Click()
Dim rsMtrData As New ADODB.Recordset
Dim irow As Integer
rsClose rsMtrData
rsMtrData.Open "select * from Master_Meter_Reading ", cn, adOpenKeyset, adLockPessimistic
With MSFlexGrid1
rsMtrData.AddNew
For irow = 0 To .Rows - 1
.Row = irow
.Col = 0
rsMtrData!Snapshot = .text & ""
.Col = 1
rsMtrData!LoadSurveyDTime = Format(.text, "dd-MM-yyyy hh:mm:SS")
.Col = 2
rsMtrData!LoadSurveyDateDay = g_ConvertNumber(.text)
.Col = 3
rsMtrData!LoadSurveyDate = Format(.text, g_DateFormat)
.Col = 4
rsMtrData!LoadSurveyDateParmVal = g_ConvertNumber(.text)
.Col = 5
rsMtrData!LoadSurveyType = .text & ""
.Col = 6
rsMtrData!LoadSurveyUnit = g_ConvertNumber(.text)
.Col = 7
rsMtrData!LoadSurveySlipValParmVal = .text & ""
.Col = 8
rsMtrData!LoadSurveySlipValParmValTime = g_ConvertNumber(.text)
rsMtrData.Update
Next irow
End With
MsgBox "Data Successfully Saved", vbInformation
End Sub
You are only adding one record then updating it. At the moment the AddNew is on the outside of the loop. If you change the code and move the AddNew inside the For..Next loop it should add more rows.
Your code would look something like this:
Private Sub cmdPrint_Click()
Dim rsMtrData As New ADODB.Recordset
Dim irow As Integer
rsClose rsMtrData
rsMtrData.Open "select * from Master_Meter_Reading ", cn, adOpenKeyset, adLockPessimistic
With MSFlexGrid1
For irow = 0 To .Rows - 1
rsMtrData.AddNew 'This is the line that has moved from outside to inside the loop.
.Row = irow
.Col = 0
rsMtrData!Snapshot = .text & ""
.Col = 1
rsMtrData!LoadSurveyDTime = Format(.text, "dd-MM-yyyy hh:mm:SS")
.Col = 2
rsMtrData!LoadSurveyDateDay = g_ConvertNumber(.text)
.Col = 3
rsMtrData!LoadSurveyDate = Format(.text, g_DateFormat)
.Col = 4
rsMtrData!LoadSurveyDateParmVal = g_ConvertNumber(.text)
.Col = 5
rsMtrData!LoadSurveyType = .text & ""
.Col = 6
rsMtrData!LoadSurveyUnit = g_ConvertNumber(.text)
.Col = 7
rsMtrData!LoadSurveySlipValParmVal = .text & ""
.Col = 8
rsMtrData!LoadSurveySlipValParmValTime = g_ConvertNumber(.text)
rsMtrData.Update
Next irow
End With
MsgBox "Data Successfully Saved", vbInformation
End Sub
Related
We have 4 Html pages that we are joining together into 1 file.
For the first page, we are reading a blank PDF file (letter head) to add as the background and then add the further 3 pages.
However, all seemed ok in version 8, but now the second page will not show.
thedoc reads the blank pdf and then the html page which overlays the text no issue here.
thedoc1 is the second page which will not load
thedoc1a and thedoc2 load ok.
If I remove the adding of the letter head from thedoc, then all 4 pages load ok, but as soon as I try and use the letter head, the second page doesnt load.
Ive added my script below. What I am doing wrong please
Sub page_load()
Dim rs
Dim strSQLQuery As String
Dim theDoc As Doc = New Doc()
Dim theDoc1 As Doc = New Doc()
Dim theDoc1a As Doc = New Doc()
Dim theDoc2 As Doc = New Doc()
Dim theDoccontents As Doc = New Doc()
theDoc.MediaBox.String = "A4"
theDoc1.MediaBox.String = "A4"
theDoc1a.MediaBox.String = "A4"
theDoc2.MediaBox.String = "A4
theDoc.HtmlOptions.PageCacheEnabled = False
theDoc.HtmlOptions.PageCacheClear()
theDoc.HtmlOptions.ImageQuality = 33
theDoc1.HtmlOptions.ImageQuality = 33
theDoc1a.HtmlOptions.ImageQuality = 33
theDoc2.HtmlOptions.ImageQuality = 33
theDoc.HtmlOptions.AddLinks = True
theDoc1.HtmlOptions.AddLinks = True
theDoc1a.HtmlOptions.AddLinks = True
theDoc2.HtmlOptions.AddLinks = True
theDoc.HtmlOptions.Timeout = 10000000
theDoc1.HtmlOptions.Timeout = 10000000
theDoc1a.HtmlOptions.Timeout = 10000000
theDoc2.HtmlOptions.Timeout = 10000000
Dim rbrandchosen As String
Dim quotenumber As String
Dim rnum As String
Dim cover as string
dim pagex as integer
quotenumber=request("quotenumber")
rbrandchosen=request("rbrandchosen")
response.write(quotenumber)
Dim theURL As String
Dim theID As Integer
Dim strsql as string
Dim theSection as string
Dim theCountDoc1a As Integer
Randomize()
rnum = (CInt(Math.Floor(90 * Rnd())) + 10).ToString
' add covering letter
cover = "c:\\inetpub\\wwwroot\\icopalukintranet\\pnf\\letterhead.pdf"
theDoc.Read(cover)
'theID = theDoc.AddObject("<< >>")
theDoc.HtmlOptions.UseScript = True
theDoc.HtmlOptions.Engine = EngineType.Chrome86
' Render after 2 seconds
theDoc.Rect.SetRect(20, 110, 600, 620)
theDoc.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 3000); })();"
theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfletter.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
'theDoc.AddImageUrl(theURL)
theID = theDoc.AddImageUrl(theURL)
While True
If Not theDoc.Chainable(theID) Then
Exit While
End If
theDoc.Page = theDoc.AddPage()
theID = theDoc.AddImageToChain(theID)
End While
' add quote
theDoc1.HtmlOptions.Engine = EngineType.Chrome86
theDoc1.HtmlOptions.UseScript = True
theDoc1.Rect.SetRect(0, 0, 600, 820)
' Render after 2 seconds
theDoc1.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 2000); })();"
theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfquote.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
theDoc1.Page = theDoc1.AddPage()
theID = theDoc1.AddImageUrl(theURL)
While True
If Not theDoc1.Chainable(theID) Then
Exit While
End If
theSection = "Quote"
theDoc1.Page = theDoc1.AddPage()
theID = theDoc1.AddImageToChain(theID)
theDoc1.AddBookmark(theSection, True)
End While
' add notes
theDoc1a.HtmlOptions.Engine = EngineType.Chrome86
theDoc1a.HtmlOptions.UseScript = True
theDoc1a.Rect.SetRect(0, 0, 600, 820)
' Render after 3 seconds
theDoc1a.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 1000); })();"
theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfnotes.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
theDoc1a.Page = theDoc1a.AddPage()
theID = theDoc1a.AddImageUrl(theURL)
While True
If Not theDoc1a.Chainable(theID) Then
Exit While
End If
theDoc1a.Page = theDoc1a.AddPage()
theID = theDoc1a.AddImageToChain(theID)
End While
' add terms details
theDoc2.HtmlOptions.Engine = EngineType.Chrome86
theDoc2.HtmlOptions.UseScript = True
theDoc2.Rect.SetRect(20, 80, 560, 710)
theDoc2.Transform.Magnify(0.93 ,0.93, 0, 690)
' Render after 1 seconds
theDoc2.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 2000); })();"
theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfterms.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
theDoc2.Page = theDoc2.AddPage()
theID = theDoc2.AddImageUrl(theURL)
While True
If Not theDoc2.Chainable(theID) Then
Exit While
End If
theSection = "Terms"
theDoc2.Page = theDoc2.AddPage()
theID = theDoc2.AddImageToChain(theID)
theDoc2.AddBookmark(theSection, True)
End While
Dim cst = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("rooflightquotes.mdb")
Dim conn = CreateObject("ADODB.Connection")
conn.open(cst)
Session("myConn") = conn
dim rsAddquestion = Server.CreateObject("ADODB.Recordset")
strsql ="select * from pdfs where id=" & quotenumber & " "
rsAddquestion.Open(strsql, conn, 3, 3)
dim n as string
n=rsAddquestion.recordcount
rsAddquestion.AddNew
n=n+1
rsAddquestion("id")=quotenumber
rsAddquestion("pdfname") =quotenumber +"-rev"+n+".pdf"
rsAddquestion("printdate")=now()
rsAddquestion("status")="Printed"
rsAddquestion.update
rsAddquestion = Server.CreateObject("ADODB.Recordset")
strsql ="select * from header where id=" & quotenumber & " "
rsAddquestion.Open(strsql, conn, 3, 3)
rsAddquestion("status")="Printed"
rsAddquestion.update
conn.close
' add the pdf together in selected order
theDoc.Append(theDoc1)
theDoc.Append(theDoc1a)
theDoc.Append(theDoc2)
Dim theCount = theDoc.PageCount
' left bottom width heght
theDoc.Rect.String = "10 10 580 25"
theDoc.HPos = 1.0
theDoc.VPos = 0.5
theDoc.Color.String = "255 255 255"
theDoc.Font = theDoc.AddFont("Arial")
theDoc.FontSize = 10
For i = 1 To theCount
theDoc.PageNumber = i
If i <> 1 Then
theDoc.AddHtml(" Page " + i.ToString() + " of " + theCount.ToString() + "")
theDoc.FrameRect()
End If
Next
dim pdffilenamec = "pdf/"+quotenumber+"-rev"+n+".pdf"
theDoc.Save(Server.MapPath(pdffilenamec))
'response.redirect("rooflightquotepdfmenu.asp?quotenumber="+quotenumber)
End Sub
This used to work find in version 8, but not now using version 12
I have several .xlsm templates in a folder. I'm trying to read through all the excel files in that folder and based on the type of the file, it reads through all the sheets in each file and copy specific cells into another my active workbook (ThisWorkbook).
Following is my code and it is working correctly. However it is super slow. I'm looking for any solution that can speed up the code. I've already tried Application.ScreenUpdating = False but still it is very slow. It takes about 10 min for 20 files to be processed.
DO you guys have any suggestion on how to increase the speed.
Thanks Veru mich in Advance
...
Application.ScreenUpdating = False
FileType = "*.xls*"
OutputRow = 5
Range("$B$6:$M$300").ClearContents
filepath = Range("$B$3") & "\"
ThisWorkbook.ActiveSheet.Range("B" & OutputRow).Activate
OutputRow = OutputRow + 1
Curr_File = Dir(filepath & FileType)
Do Until Curr_File = ""
Set FldrWkbk = Workbooks.Open(filepath & Curr_File, False, True)
ThisWorkbook.ActiveSheet.Range("B" & OutputRow) = Curr_File
OutputRow = OutputRow
For Each sht In FldrWkbk.Sheets
ThisWorkbook.ActiveSheet.Range("C" & OutputRow) = sht.Name
If Workbooks(Curr_File).Worksheets(sht.Name).Range("B7") = "Project Number" Then
For i = 1 To 4
If IsEmpty(Workbooks(Curr_File).Worksheets(sht.Name).Cells(10, 5 + 2 * i)) = False Then
With Workbooks(Curr_File).Worksheets(sht.Name)
MyE = .Cells(10, 5 + 2 * i).Value
MyF = .Cells(11, 5 + 2 * i).Value
End With
With ThisWorkbook.ActiveSheet
.Range("D" & OutputRow).Value = "Unit Weight"
.Range("E" & OutputRow).Value = MyE
.Range("F" & OutputRow).Value = MyF
End With
OutputRow = OutputRow + 1
End If
Next
OutputRow = OutputRow - 1
ElseIf Workbooks(Curr_File).Worksheets(sht.Name).Range("C6") = "PROJECT NUMBER" Then
With Workbooks(Curr_File).Worksheets(sht.Name)
MyE = .Range("$H$9").Value
MyF = .Range("$B$9").Value
End With
With ThisWorkbook.ActiveSheet
.Range("D" & OutputRow).Value = "Specific Gravity"
.Range("E" & OutputRow).Value = MyE
.Range("F" & OutputRow).Value = MyF
End With
ElseIf Workbooks(Curr_File).Worksheets(sht.Name).Range("C6") = "Project Number" Then
With Workbooks(Curr_File).Worksheets(sht.Name)
MyE = .Range("$E$4").Value
MyF = .Range("$R$4").Value
MyG = .Range("$R$5").Value
End With
With ThisWorkbook.ActiveSheet
.Range("D" & OutputRow).Value = "Sieve & Hydrometer"
.Range("E" & OutputRow).Value = MyE
.Range("F" & OutputRow).Value = MyF
.Range("G" & OutputRow).Value = MyG
End With
ElseIf Workbooks(Curr_File).Worksheets(sht.Name).Range("A6") = "PROJECT NUMBER" Then
ThisWorkbook.ActiveSheet.Range("D" & OutputRow).Value = "Moisture Content"
Last = Workbooks(Curr_File).Worksheets(sht.Name).Cells(Rows.Count, "J").End(xlUp).Row
ThisWorkbook.ActiveSheet.Range("I" & OutputRow).Value =
Workbooks(Curr_File).Worksheets(sht.Name).Cells(Last, 10)
ElseIf Workbooks(Curr_File).Worksheets(sht.Name).Range("C5") = "Project Number" Then
With Workbooks(Curr_File).Worksheets(sht.Name)
MyE = .Range("$H$8").Value
MyF = .Range("$B$8").Value
MyG = .Range("$D$8").Value
End With
With ThisWorkbook.ActiveSheet
.Range("D" & OutputRow).Value = "Atterberg Limits"
.Range("E" & OutputRow).Value = MyE
.Range("F" & OutputRow).Value = MyF
.Range("G" & OutputRow).Value = MyG
End With
ElseIf Workbooks(Curr_File).Worksheets(sht.Name).Range("B5") = "Project Number" Then
With Workbooks(Curr_File).Worksheets(sht.Name)
MyE = .Range("$G$4").Value
MyF = .Range("$E$4").Value
MyG = .Range("$E$5").Value
End With
With ThisWorkbook.ActiveSheet
.Range("D" & OutputRow).Value = "Gradation Size"
.Range("E" & OutputRow).Value = MyE
.Range("F" & OutputRow).Value = MyF
.Range("G" & OutputRow).Value = MyG
End With
End If
OutputRow = OutputRow + 1
Next sht
FldrWkbk.Close SaveChanges:=False
Curr_File = Dir
Loop
Set FldrWkbk = Nothing
Application.ScreenUpdating = True
...
I Just realized that the slow performance is due to the formulations that are written in the excel but are linked to the ranges that are pasted from the Macro code. As it was addressed in the previous stack overflow solutions, I simply added "Application.Calculation = xlCalculationManual" in the beginning of the code and "Application.Calculation = xlCalculationAutomatic" at the end of the code and now it is much much faster.
I hope it is also useful to whom is reading this
I try to export to Excel with the fpsread plugin, but there really is no information on how, I have searched the manual but they only show me how to do it with .net
Will someone have an idea?
I managed to do it was very simple, but wanting to import the titles was the heaviest, but here I leave the code in case any work
Private Sub CmdImportar_Click()
Call Export_Excel(cdgExcel, sprFacturas)
Call HacerBusqueda
End Sub
Public Sub Export_Excel(cdgExcel As CommonDialog, Spread As fpSpread)
Dim Header() As String
Dim I As Integer
Dim j As Integer
Dim x As Integer
With cdgExcel
.CancelError = False
.InitDir = "C:/:"
.Filter = "Excel(*.xls)|*.xls"
.ShowSave
If .filename <> "" Then
Spread.Redraw = False
For I = 1 To Spread.ColHeaderRows
ReDim Header(Spread.MaxCols) As String
Spread.Row = SpreadHeader + (I - 1)
For j = 1 To Spread.MaxCols
Spread.Col = j
Header(j) = Spread.Text & ""
Next j
Spread.MaxRows = Spread.MaxRows + 1
Spread.Row = I
Spread.Action = ActionInsertRow
For j = 1 To Spread.MaxCols
Spread.Col = j
Spread.CellType = Spread.CellType
Spread.TypeHAlign = Spread.TypeHAlign
Spread.TypeVAlign = Spread.TypeVAlign
Spread.Text = Header(j) & ""
Next j
Next I
x = Spread.ExportToExcel(.filename, "Sheet1", "")
For I = 1 To Spread.ColHeaderRows
Spread.Row = 1
Spread.Action = ActionDeleteRow
Next I
If x = True Then
MsgBox .filename & vbNewLine & "Se ha Importado el archivo", vbInformation, "Resultado"
Else
MsgBox "No se ha podido exportar el archivo", vbCritical, "Error"
End If
End If
End With
End Sub
I have a VB6 project that is using a SQL2008 database. The project consists of two Combo Boxes , a MSHFlexGrid, and Two Command Buttons(cmdLoadSeries & cmdExit). The user will make a selection from the first Combo box and press the cmdLoadSeries command button which populates the 2nd combo box and the MSHFlexgrid. I am using a text box to manipulate the info in the grid.
The First time I select a line in the mshflexgrid it selects/Highlights the row i clicked on and everything above it as well. After the first time, it only selects/highlights the row I clicked on. Why? Please help.
Here is my code:
Private Sub cmdLoadSeries_Click()
Const cProcName = msModuleName & "cmdLoadSeries"
'Too save space I removed the code that retrieves MRecordSet.
If mRecordSet.RecordCount > 0 Then
LoadControls
SetFormFields True
DataCombo1.BoundText = mRecordSet2.Fields(0)
Else
LoadControls
cmdExit.Enabled = True
End If
cmdLoadSeries.Enabled = False
Combo1.Enabled = False
End Sub
Private Sub LoadControls()
Const cProcName = msModuleName & "LoadControls"
With mRecordSet
OpenRSFlexGrid1
FillFlexGrid1
End With
End Sub
Sub OpenRSFlexGrid1
'This code setups a recordset used to populate the mshflexgrid with
End Sub
Sub FillFlexGrid1(Optional pbClear As Boolean)
Const cProcName = msModuleName & "FillFlexGrid1"
Dim llCntrRow As Integer
Dim llCntrCol As Integer
Dim max_len As Single
Dim new_len As Single
Dim liCntr As Integer
Dim llCol As Long
Text1.BorderStyle = 0
With MSFlexGrid1
MSFlexGrid1.Clear
Text1.FontName = .FontName
Text1.FontSize = .FontSize
Text1.Visible = False
.Cols = mRecordset4.Fields.Count
.FixedCols = 1
If mRecordset4.RecordCount > 0 And (Not pbClear = True) Then
.Rows = mRecordset4.RecordCount + 1
.FixedRows = 1
Else
.Rows = 2
.FixedRows = 1
End If
For llCntrCol = 0 To .Cols - 1
.TextMatrix(0, llCntrCol) = mRecordset4.Fields(llCntrCol).Name
Next
If mRecordset4.RecordCount > 0 And (Not pbClear = True) Then
mRecordset4.MoveFirst
For llCntrRow = 1 To mRecordset4.RecordCount
For llCntrCol = 0 To .Cols - 1
.TextMatrix(llCntrRow, llCntrCol) = Trim(CStr(mRecordset4.Fields(llCntrCol).Value))
Next
mRecordset4.MoveNext
Next
Else
For llCntrCol = 0 To .Cols - 1
.TextMatrix(.FixedRows, llCntrCol) = ""
Next
End If
Font.Name = MSFlexGrid1.Font.Name
Font.Size = MSFlexGrid1.Font.Size
For llCntrCol = 0 To MSFlexGrid1.Cols - 1
max_len = 0
If .TextMatrix(0, llCntrCol) = "setoutid" Then
MSFlexGrid1.ColWidth(llCntrCol) = TextWidth("W") * 0.54
Else
For llCntrRow = 0 To MSFlexGrid1.Rows - 1
new_len = TextWidth(MSFlexGrid1.TextMatrix(llCntrRow, llCntrCol))
If max_len < new_len Then max_len = new_len
Next llCntrRow
Dim lsFillColumn As String
lsFillColumn = String(42, "W")
If .TextMatrix(0, llCntrCol) = "setoutname" And TextWidth(lsFillColumn) > max_len Then
max_len = TextWidth(lsFillColumn)
End If
MSFlexGrid1.ColWidth(llCntrCol) = max_len + (TextWidth("W") * 1.5)
MSFlexGrid1.ColAlignment(llCntrCol) = flexAlignLeftCenter
End If
Next llCntrCol
.Col = .FixedCols
.Row = .FixedRows
End With
Exit Sub
errFillFlexGrid1:
Resume Next
End Sub
Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
Const cProcName = msModuleName & "MSFlexGrid1_KeyDown"
On Error GoTo errhandle
With MSFlexGrid1
If Text1.Visible = False Then
Select Case KeyCode
Case 45
If Shift = 1 Then
.AddItem "", .Row + 1
Else
.AddItem "", .Row
End If
mbFlexGrid1Changed = True
Case 46
If MSFlexGrid1.Rows = .FixedRows + 1 Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows + .FixedRows - 1
Else
.RemoveItem .Row
End If
mbFlexGrid1Changed = True
End Select
End If
End With
Exit Sub
errhandle:
Resume Next
End Sub
Private Sub Text1_LostFocus()
Const cProcName = msModuleName & "Text1_LostFocus"
On Error GoTo errhandle
If Text1.Visible Then
MSFlexGrid1.Text = Text1.Text
End If
Text1.Visible = False
Exit Sub
errhandle:
Resume Next
End Sub
Private Sub MSFlexGrid1_GotFocus()
Const cProcName = msModuleName & "MSFlexGrid1_GotFocus"
On Error GoTo errhandle
bLostFocus = False
pSetTabStop (True)
If mlCurrentCol > 0 Then
MSFlexGrid1.Col = mlCurrentCol
MSFlexGrid1.Row = mlCurrentRow
End If
mlCurrentCol = 0
mlCurrentRow = 0
If Text1.Visible Then
MSFlexGrid1.Text = Text1.Text
Text1.Visible = False
End If
Exit Sub
errhandle:
Resume Next
End Sub
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
Const cProcName = msModuleName & "MSFlexGrid1_KeyPress"
On Error GoTo errhandle
Select Case KeyAscii
Case 27
If Text1.Visible Then
Text1.Visible = False
End If
Case Else
FlexGridEdit KeyAscii
End Select
Exit Sub
errhandle:
Resume Next
End Sub
Private Sub MSFlexGrid1_LeaveCell()
Const cProcName = msModuleName & "MSFlexGrid1_LeaveCell"
On Error GoTo errhandle
If Text1.Visible Then
MSFlexGrid1.Text = Text1.Text
Text1.Visible = False
End If
Exit Sub
errhandle:
Resume Next
End Sub
Private Function FlexGridChkPos(KeyCode As Integer) As Boolean
Dim llNextRow As Long
Dim llNextCol As Long
Dim llCurrCol As Long
Dim llCurrRow As Long
Dim llTotCols As Long
Dim llTotRows As Long
Dim llBegRow As Long
Dim llBegCol As Long
Dim llCntrCol As Long
Dim lsText As String
Const cProcName = msModuleName & "FlexGridChkPos"
On Error GoTo errhandle
With MSFlexGrid1
llCurrRow = .Row + 1
llCurrCol = .Col + 1
llTotRows = .Rows
llTotCols = .Cols
llBegRow = .FixedRows
llBegCol = .FixedCols
If KeyCode = vbKeyRight Or KeyCode = vbKeyReturn Then
llNextCol = llCurrCol + 1
If llNextCol > llTotCols Then
llNextRow = llCurrRow + 1
If llNextRow > llTotRows Then
GoSub LogLine
.Rows = .Rows + 1
llCurrRow = llCurrRow + 1
llCurrCol = 1 + llBegCol
Else
llCurrRow = llNextRow
llCurrCol = 1 + llBegCol
End If
Else
llCurrCol = llNextCol
End If
End If
If KeyCode = vbKeyLeft Then
llNextCol = llCurrCol - 1
If llNextCol = llBegCol Then
llNextRow = llCurrRow - 1
If llNextRow = llBegRow Then
llCurrRow = llTotRows
Else
llCurrRow = llNextRow
End If
llCurrCol = llTotCols
Else
llCurrCol = llNextCol
End If
End If
.Col = llCurrCol - 1
.Row = llCurrRow - 1
End With
Exit Function
LogLine:
lsText = ""
Return
errhandle:
Resume Next
End Function
The .row parameter was not being set correctly upon first entering the grid.
I'm using data report in VB 6 and trying to display images from database. It retrieves the image but showing the same image for all output
the code i'm using are given below
Dim rs As ADODB.Recordset, rs1 As ADODB.Recordset
Dim a As String
k = 0
i = 0
j = 0
k = 0
Set rs = New ADODB.Recordset
With rs
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = conn
.Source = "SELECT patientid FROM Inpatients_Maintenance WHERE (ModDate >= '" & frmDate & "') AND (ModDate <= '" & endDate & "')"
.CursorLocation = adUseClient
.Open
Do Until rs.EOF
If (rs.EOF = False And rs.BOF = False) Then
pid(i) = rs.Fields(0).Value
End If
i = i + 1
rs.MoveNext
Loop
End With
Set rs = Nothing
Set rs1 = New ADODB.Recordset
Dim id As String
With rs1
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = conn
For j = 0 To i - 1
id = pid(j)
.Source = "Select photo from patientImage where patientid='" & id & "'"
.CursorLocation = adUseClient
.Open
If (rs1.EOF = False And rs1.BOF = False) Then
p(j) = App.Path + "\patients\" + rs1.Fields(0).Value
a = p(j)
Set RptInpatientMaster.Sections("Section1").Controls("Image2").Picture = LoadPicture(a)
End If
.Close
Next j
End With
Do you only see the last one?
Set RptInpatientMaster.Sections("Section1").Controls("Image2").Picture = LoadPicture(a)
you always refer to same picture inside your report, isn't it?