L
lmv
I have records in the product table that I want to use to append records to
orders detail table. I have a multiselect form that I "found" which is very
nice.
It allows sending the cked records to a report to view on the fly... is it
possible to do append to another table the same way with another cmdButton?
If so how would you write the code...
Thanks!
lmv
Below is all the code...
Option Compare Database
Option Explicit
Dim colCheckBox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckBox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub Check11_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
KeyCode = 0
Call Command13_Click
End If
End Sub
Private Sub Command13_Click()
'Debug.Print "Product = " & Me.ProductID
If IsChecked(Me.ProductID) = False Then
colCheckBox.Add CLng(Me.ProductID), CStr(Me.ProductID)
Else
colCheckBox.Remove (CStr(Me.ProductID))
End If
Me.Check11.Requery
End Sub
Private Sub Command14_Click()
MsgBox "records selected = " & MySelected, vbInformation, "Multi Select
example"
End Sub
Private Function MySelected() As String
Dim I As Integer
For I = 1 To colCheckBox.Count
If MySelected <> "" Then
MySelected = MySelected & ","
End If
MySelected = MySelected & colCheckBox(I)
Next I
End Function
Private Sub Command16_Click()
Dim strWhere As String
strWhere = MySelected
If strWhere <> "" Then
strWhere = "ProductID in (" & strWhere & ")"
End If
DoCmd.OpenReport "rptOrders", acViewPreview, , strWhere
DoCmd.RunCommand acCmdZoom100 ' this is optional
End Sub
Private Sub Command17_Click()
Set colCheckBox = Nothing
Me.Requery
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' key hand
Select Case KeyCode
Case vbKeyUp
KeyCode = 0
On Error Resume Next
DoCmd.GoToRecord acActiveDataObject, , acPrevious
Case vbKeyDown
KeyCode = 0
On Error Resume Next
DoCmd.GoToRecord acActiveDataObject, , acNext
' Case vbKeyReturn
' If IsNull(Me.ID) = False Then
' KeyCode = 0
' Call EditMain
' End If
End Select
End Sub
Private Sub Form_Load()
Me.ProductName.SetFocus
End Sub
Private Sub ProductName_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Function ChangeOrderBy(strFieldName As String) As Boolean
Dim strActiveCtlName As String
Dim strOrderby As String
strOrderby = Me.OrderBy
strActiveCtlName = Screen.ActiveControl.name
If Me.OrderBy = strFieldName Then
Me.OrderBy = strFieldName & " Desc"
Else
Me.OrderBy = strFieldName
End If
Me.OrderByOn = True
ChangeOrderBy = True
End Function
orders detail table. I have a multiselect form that I "found" which is very
nice.
It allows sending the cked records to a report to view on the fly... is it
possible to do append to another table the same way with another cmdButton?
If so how would you write the code...
Thanks!
lmv
Below is all the code...
Option Compare Database
Option Explicit
Dim colCheckBox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckBox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub Check11_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
KeyCode = 0
Call Command13_Click
End If
End Sub
Private Sub Command13_Click()
'Debug.Print "Product = " & Me.ProductID
If IsChecked(Me.ProductID) = False Then
colCheckBox.Add CLng(Me.ProductID), CStr(Me.ProductID)
Else
colCheckBox.Remove (CStr(Me.ProductID))
End If
Me.Check11.Requery
End Sub
Private Sub Command14_Click()
MsgBox "records selected = " & MySelected, vbInformation, "Multi Select
example"
End Sub
Private Function MySelected() As String
Dim I As Integer
For I = 1 To colCheckBox.Count
If MySelected <> "" Then
MySelected = MySelected & ","
End If
MySelected = MySelected & colCheckBox(I)
Next I
End Function
Private Sub Command16_Click()
Dim strWhere As String
strWhere = MySelected
If strWhere <> "" Then
strWhere = "ProductID in (" & strWhere & ")"
End If
DoCmd.OpenReport "rptOrders", acViewPreview, , strWhere
DoCmd.RunCommand acCmdZoom100 ' this is optional
End Sub
Private Sub Command17_Click()
Set colCheckBox = Nothing
Me.Requery
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' key hand
Select Case KeyCode
Case vbKeyUp
KeyCode = 0
On Error Resume Next
DoCmd.GoToRecord acActiveDataObject, , acPrevious
Case vbKeyDown
KeyCode = 0
On Error Resume Next
DoCmd.GoToRecord acActiveDataObject, , acNext
' Case vbKeyReturn
' If IsNull(Me.ID) = False Then
' KeyCode = 0
' Call EditMain
' End If
End Select
End Sub
Private Sub Form_Load()
Me.ProductName.SetFocus
End Sub
Private Sub ProductName_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Function ChangeOrderBy(strFieldName As String) As Boolean
Dim strActiveCtlName As String
Dim strOrderby As String
strOrderby = Me.OrderBy
strActiveCtlName = Screen.ActiveControl.name
If Me.OrderBy = strFieldName Then
Me.OrderBy = strFieldName & " Desc"
Else
Me.OrderBy = strFieldName
End If
Me.OrderByOn = True
ChangeOrderBy = True
End Function