>Hi Frank,
>I'm not sure this is the best way to do this. How about a preset option in frmOptions for the >number of rows.
>Then when the query is run, we say:
>The query returned more than XXX rows. Do you wish to LIMIT the output?
>Yes/No/Cancel
>Yes = Limit
>No = Return all rows
>Cancel = Abort
>What do you think?
>Regards, Dave.
Sub corrected using your suggestions:
Private Sub mnuPopupViewData_Click()
On Error GoTo Err_Handler
svr.LogEvent "Entering " & App.Title & ":frmMain.mnuPopupViewData_Click()", etFullDebug
Dim objOutputForm As New frmSQLOutput
Dim rsQuery As New Recordset
Dim iMsgBoxResult As VbMsgBoxResult
Dim szLimit As String
Dim szTemp As String
Const ROW_LIMIT As Integer = 5000
'count row
StartMsg "Counting Records..."
Set rsQuery = frmMain.svr.Databases(ctx.CurrentDB).Execute("SELECT count(*) AS count FROM "
& ctx.C
u
rrentObject.FormattedID)
EndMsg
'verify limit output
szLimit = ""
If Not rsQuery.EOF Then
If rsQuery!Count > ROW_LIMIT Then
iMsgBoxResult = MsgBox("The query returned more than " & rsQuery!Count & " rows. Do you wish to LIMIT the
output?",vbApplicationModal + vbYesNoCancel + vbQuestion, "Row limit")
If iMsgBoxResult = vbCancel Then
Exit Sub
ElseIf iMsgBoxResult = vbYes Then
szTemp = InputBox("Insert row limit" & vbCrLf & "Table contain " & rsQuery!Count & " rows", "Row limit",
ROW_LIMIT)
If Not IsNumeric(szTemp) Then Exit Sub
szLimit = " LIMIT " & szTemp
End If
End If
End If
StartMsg "Executing SQL Query..."
Set rsQuery = frmMain.svr.Databases(ctx.CurrentDB).Execute("SELECT * FROM " & ctx.CurrentObject.FormattedID &
szLimit)
Load objOutputForm
objOutputForm.Display rsQuery,
ctx.Cur
r
entDB, "(" & ctx.CurrentObject.ObjectType & ": " & ctx.CurrentObject.FormattedID & ")"
objOutputForm.Show
EndMsg
Exit Sub
Err_Handler:
EndMsg
If Err.Number <> 0 Then LogError Err.Number, Err.Description, App.Title & ":frmMain.mnuPopupViewData_Click"
End Sub
Bye !!
Frank Lupo (Wolf) !!
/\_ _/\
\ o o /
--ooo-----ooo---
--
Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f
Sponsor:
Natsabe.it la più grande erboristeria online italiana
con consegna gratuita a partire da soli 50 euro !
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=1307&d=28-2