Topic: Parameter in request in VB a script
There is a form, on it the button.
It is necessary for me that on button click it was formed an ex-fur-tree of result of my request.
But in my request there is a parameter, which user hands enters.
And at button click at me few parameters swear that though to enter parameter a window do not show.
Request of type:
SELECT * FROM TABLE1 WHERE Date = [Enter date:];
Anchored to the button procedure:
Private Sub Knopka36_Click () On Error GoTo Err1 ' Variables Dim XLApp As Object, XLBook As Object, XLSheet As Object, RS As Object Dim CountColumn As Integer, WidthColumn As Integer, StrSQLInExcel As String ' we Create objects: Excel, the Book, Sheet Set XLApp = CreateObject ("Excel. Application") Set XLBook = XLApp. Workbooks. Add Set XLSheet = XLBook. Worksheets (1) Set RS = CurrentDb. OpenRecordset ("Test") ' we Learn an amount of columns in Recordset CountColumn = RS.Fields. Count ' with the Cycle we fill titles of columns For i = 0 To CountColumn - 1 ' we Move on columns in Excel by offset XLSheet. Range ("A1").offset (0, i).Value = RS.Fields (i).Name ' we correct appearance of outswapping a little ' Width of a column we define dynamic on the basis of field length, but no more than 20 and not less 6 WidthColumn = Len (RS.Fields (i).Name) + 2 If WidthColumn> 20 Then WidthColumn = 20 ElseIf WidthColumn <6 Then WidthColumn = 10 End If ' we Set for title ' Transfer by words XLSheet. Rows (1).WrapText = True ' Alignment ' Background color XLSheet. Rows (1).Interior. ColorIndex = 15 ' Width XLSheet. Columns (i + 1).ColumnWidth = WidthColumn Next ' It is writeable Recordset in Excel XLSheet. Range ("A2").CopyFromRecordset RS ' It is done visible Excel XLApp. Visible = True ' It is closed Recordset RS.Close Set RS = Nothing Ex1: Exit Sub Err1: MsgBox Err. Description Resume Ex1 End Sub