I wanted to create a database to store IT Event Logs, IT Inventory, System Info, and User Info. I thought I would challenge myself and use an AlphaFive database. My boss like the old Alpha and he's trying to migrate to AlphaFive. My attempts... well they didn't really work out too well. I found myself strugling to get fairly regular filtering and sorting activites to happen in the database. Yes, it has the capacity to do these things, yet I wanted to create standard filters and sorts at the click of a button. As well, I was having issue with comboboxes in Alpha performing lookups in other tables. So I switched to Access. Under the cut you can see the Visual Basic code I ended up using for the various buttons and combo boxes I used to create sorts and filters.
Option Compare Database
Private Sub CmdSortCatID_Click()
On Error GoTo Err_CmdSortCatID_Click
InventoryDataViewSub.SetFocus
InventoryDataViewSub!CategoryID.SetFocus
DoCmd.RunCommand acCmdSortAscending
Exit_CmdSortCatID_Click:
Exit Sub
Err_CmdSortCatID_Click:
MsgBox Err.Description
Resume Exit_CmdSortCatID_Click
End Sub
Private Sub CmdSortLocID_Click()
On Error GoTo Err_CmdSortLocID_Click
InventoryDataViewSub.SetFocus
InventoryDataViewSub!LocationID.SetFocus
DoCmd.RunCommand acCmdSortAscending
Exit_CmdSortLocID_Click:
Exit Sub
Err_CmdSortLocID_Click:
MsgBox Err.Description
Resume Exit_CmdSortLocID_Click
End Sub
Private Sub ComboCatIDFilter_Change()
Dim UnitCatIDFilter As String
UnitCatIDFilter = "[CategoryID] = " & ComboCatIDFilter.Text
TxtResults.Value = UnitCatIDFilter
InventoryDataViewSub.Form.FilterOn = True
InventoryDataViewSub.Form.Filter = UnitCatIDFilter
End Sub
Private Sub ComboFilterByMake_Change()
Dim UnitMakeFilter As String
UnitMakeFilter = "[UnitMake] = '" & ComboFilterByMake.Text & "'"
TxtResults.Value = UnitMakeFilter
InventoryDataViewSub.Form.FilterOn = True
InventoryDataViewSub.Form.Filter = UnitMakeFilter
End Sub
Private Sub ComboLocIDFilter_Change()
Dim UnitLocIDFilter As String
UnitLocIDFilter = "[LocationID] = " & ComboLocIDFilter.Text
TxtResults.Value = UnitLocIDFilter
InventoryDataViewSub.Form.FilterOn = True
InventoryDataViewSub.Form.Filter = UnitLocIDFilter
End Sub
Private Sub TxtValueFilter_LostFocus()
ComboValueOp.SetFocus
Dim OpValue As String
Dim UnitValueFilter As String
OpValue = ComboValueOp.Text
UnitValueFilter = "[UnitValue] " & OpValue & " " & TxtValueFilter.Value
'Constructed filter condition: [UnitValue] (=,<,<=,>,>=,<>) (INTEGER)
TxtResults.Value = UnitValueFilter
InventoryDataViewSub.Form.FilterOn = True
InventoryDataViewSub.Form.Filter = UnitValueFilter
End Sub
Private Sub CmdClearFilters_Click()
On Error GoTo Err_CmdClearFilters_Click
DoCmd.ShowAllRecords 'Clear all filters
Exit_CmdClearFilters_Click:
Exit Sub
Err_CmdClearFilters_Click:
MsgBox Err.Description
Resume Exit_CmdClearFilters_Click
End Sub