If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Flexgrid row counter?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-24-04, 14:46
heprox heprox is offline
Registered User
 
Join Date: Oct 2003
Posts: 54
Question Flexgrid row counter?

I have a database application that is using ODBC to query a Sybase DB then return select records to a flexgrid. Once the user has all of the records on the flexgrid that they want the hit "Save" and the application creates a flat file for import into another DB. The problem that I'm having is that the "other DB" can has a line limit on the number of records that can be in the file (1000). How do you make the flexgrid not allow more that a 1000 lines? Maybe have a msgbox that states you can only have a maximum of 999 lines? Here is the code that populates the flexgrid:


Private Sub cmdEnter_Click()
Dim strsql As String
Dim inti As Integer
Dim blnFound As Boolean
Set rs = New ADODB.Recordset
Select Case Len(txtData.Text)
Case 12
' where condition uses UPC
strsql = "SELECT PLU_Cross_Ref.plunum, xrefnum, retailprice FROM PLU_Cross_Ref, plu WHERE PLU_Cross_Ref.plunum=plu.plunum AND xrefnum='" & (txtData.Text) & "'"
Case 11
' where condition uses SKU
strsql = "SELECT PLU_Cross_Ref.plunum, xrefnum, retailprice FROM PLU_Cross_Ref, plu WHERE PLU_Cross_Ref.plunum=plu.plunum AND PLU_Cross_Ref.plunum='" & (txtData.Text) & "'"
Case Else
MsgBox " Invalid SKU/UPC", vbCritical
txtData.Text = ""
txtData.SetFocus
Exit Sub
End Select
rs.Open strsql, cn, adOpenKeyset, adLockReadOnly
If Not rs.EOF Then
blnFound = False
For inti = 1 To msfData.Rows - 1
If msfData.TextMatrix(inti, 0) = rs("xrefnum") Then
msfData.TextMatrix(inti, 3) = Val(msfData.TextMatrix(inti, 3)) + 1
blnFound = True
txtData.Text = ""
txtData.SetFocus
Exit For
End If
Next
If blnFound = False Then
If msfData.TextMatrix(1, 0) = "" Then
inti = 1
Else
inti = msfData.Rows
msfData.Rows = msfData.Rows + 1
End If
msfData.TextMatrix(inti, 0) = rs("xrefnum")
msfData.TextMatrix(inti, 1) = rs("plunum")
msfData.TextMatrix(inti, 2) = rs("retailprice")
msfData.TextMatrix(inti, 3) = 1
txtData.Text = ""
txtData.SetFocus
End If
Else
MsgBox "Invalid UPC/SKU Number!", vbCritical
txtData.Text = ""
txtData.SetFocus
Exit Sub
End If
rs.Close
Exit Sub
End Sub
Reply With Quote
  #2 (permalink)  
Old 06-25-04, 06:25
deviant69 deviant69 is offline
Registered User
 
Join Date: Jun 2004
Location: Deutschland
Posts: 10
Smile

just an idea:
you can add a counter, or a "while" function.
if the limit is reached, then the "MsgBox" or what u liem can popup, and the operation will be stoped.

deviant69
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On