The only diff between all of the grids is the query and the widows form it is on.
I basicly just copied the form changing the SQL for the datasource.
any way so here is the code i typed:
Expand|Select|Wrap|Line Numbers
- Private Sub Print_Click()
- Dim msg As Variant
- Dim spaceaftercolumn1 As Variant
- Dim spaceaftercolumn2 As Variant
- Dim Spaceaftercolumn4 As Variant
- Dim Spaceaftercolumn5 As Variant
- Dim Spaceaftercolumn8 As Variant
- msg = "Are You Sure You Want to Print All Of The Records?"
- If MsgBox(msg, vbOKCancel, "Print All") = vbOK Then
- frmallrecords.grdDataGrid.Row = 0
- Printer.Orientation = 2
- Printer.Font = "Courier New"
- Printer.FontSize = 10
- Printer.FontUnderline = True
- Printer.FontBold = True
- Printer.Print Me.Caption & Space(1) & "-" & Space(1) & Date;
- Printer.Print
- Printer.Print
- Printer.Print "Company" & Space(43) & "First Name" & Space(4) & "Tel" & Space(7) & "Mob" & Space(7) & "Last Seen" & Space(3) & "Today?"
- Printer.Font = "Courier New"
- Printer.FontSize = 10
- Printer.FontUnderline = False
- Printer.FontBold = False
- Do While Not frmallrecords.grdDataGrid.Row = datPrimaryRS.Recordset.RecordCount - 1
- spaceaftercolumn1 = 50 - Len(frmallrecords.grdDataGrid.Columns(1))
- spaceaftercolumn2 = 14 - Len(frmallrecords.grdDataGrid.Columns(2))
- Spaceaftercolumn4 = 10 - Len(frmallrecords.grdDataGrid.Columns(4))
- Spaceaftercolumn5 = 10 - Len(frmallrecords.grdDataGrid.Columns(5))
- Spaceaftercolumn8 = 12 - Len(frmallrecords.grdDataGrid.Columns(8))
- Printer.Print frmallrecords.grdDataGrid.Columns(1) & Space(spaceaftercolumn1) & frmallrecords.grdDataGrid.Columns(2) & Space(spaceaftercolumn2) & frmallrecords.grdDataGrid.Columns(4) & Space(Spaceaftercolumn4) & frmallrecords.grdDataGrid.Columns(5) & Space(Spaceaftercolumn5) & frmallrecords.grdDataGrid.Columns(8) & Space(Spaceaftercolumn8) & "______"
- frmallrecords.grdDataGrid.Row = frmallrecords.grdDataGrid.Row + 1
- Loop
- spaceaftercolumn1 = 50 - Len(frmallrecords.grdDataGrid.Columns(1))
- spaceaftercolumn2 = 14 - Len(frmallrecords.grdDataGrid.Columns(2))
- Spaceaftercolumn4 = 10 - Len(frmallrecords.grdDataGrid.Columns(4))
- Spaceaftercolumn5 = 10 - Len(frmallrecords.grdDataGrid.Columns(5))
- Spaceaftercolumn8 = 12 - Len(frmallrecords.grdDataGrid.Columns(8))
- Printer.Print frmallrecords.grdDataGrid.Columns(1) & Space(spaceaftercolumn1) & frmallrecords.grdDataGrid.Columns(2) & Space(spaceaftercolumn2) & frmallrecords.grdDataGrid.Columns(4) & Space(Spaceaftercolumn4) & frmallrecords.grdDataGrid.Columns(5) & Space(Spaceaftercolumn5) & frmallrecords.grdDataGrid.Columns(8) & Space(Spaceaftercolumn8) & "______"
- Printer.Print
- Printer.EndDoc
- End If
Can anyone suggest alternative code for that bit?
Another solution i thought of is since the error only occurs when there is no query ie Where statement in the datasource. Does any one know SQL that applies The where function *? i tried this
Expand|Select|Wrap|Line Numbers
- select * From Cutomers Where Customers.city = "*" Order by customers.Date_last_seen
Thank you for any help.!!!