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