I have the database imported from an excel spreadsheet.
I am using the Asset Template for Access (Office365 ProPlus version 1904).
The filter form and table were not needed so I removed them.
My need:
I am looking for a simple search function that allows me to Search across 4 - 5 columns for specific or keyword information in the form. I would prefer to not use a query if at all possible.
What I have done thus far:
I took the filters macro that came with the template and converted it to VBA for easier editing. (My VBA knowledge is very basic FYI) I added and removed things I knew I didn't need like setting up temp vars in reference to the Filter Details Form and Table. Under QuickSearch, I changed the filter names for the columns to the columns I had imported from the Excel Spreadsheet.
My Issue:
I am currently having an issue trying to get the Command Buttons to either call the function from the Module via Macro or to use an Event Procedure to call the specific Function from the Module.
I would graciously accept any assistance you guys can provide.
Thanks in Advance!
Code is below: - Attribute VB_Name = "Converted Macro- Filters"
-
Option Compare Database
-
-
'------------------------------------------------------------
-
' Filters
-
'
-
'------------------------------------------------------------
-
Function Filters()
-
On Error GoTo Filters_Err
-
-
Beep
-
' Macro can't be run from the navigation pane.
-
Exit Function
-
-
-
Filters_Exit:
-
Exit Function
-
-
Filters_Err:
-
MsgBox Error$
-
Resume Filters_Exit
-
-
End Function
-
-
'------------------------------------------------------------
-
' Filters_ClearFilter
-
'
-
'------------------------------------------------------------
-
Function Filters_ClearFilter()
-
On Error Goto Filters_ClearFilter_Err
-
-
With CodeContextObject
-
If (CurrentProject.IsTrusted And .Form.Name = "Asset List") Then
-
.Form!cboFilterFavorites = ""
-
End If
-
' Clear Filter
-
DoCmd.ApplyFilter "", """""", ""
-
If (.Form.Name = "Asset List" And Not (.Form!chkShowRetired)) Then
-
' Filter out Retired assets if checkbox is cleared
-
DoCmd.ApplyFilter "", Eval("""[Retired Date ] is null or [Retired Date ] > date()"""), ""
-
End If
-
DoCmd.GoToControl "txtSearchBox"
-
DoCmd.SetProperty "cmdSearchClear", acPropertyVisible, "0"
-
DoCmd.SetProperty "iconSearchClear", acPropertyVisible, "0"
-
DoCmd.SetProperty "cmdSearchGo", acPropertyVisible, "-1"
-
If (CurrentProject.IsTrusted) Then
-
.txtSearchBox = ""
-
End If
-
Exit Function
-
End With
-
-
-
Filters_ClearFilter_Exit:
-
Exit Function
-
-
Filters_ClearFilter_Err:
-
MsgBox Error$
-
Resume Filters_ClearFilter_Exit
-
-
End Function
-
-
'------------------------------------------------------------
-
' Filters_QuickSearch
-
'
-
'------------------------------------------------------------
-
Function Filters_QuickSearch()
-
On Error Goto Filters_QuickSearch_Err
-
-
With CodeContextObject
-
If (.txtSearchBox = "") Then
-
' Clear Filter when search box empty
-
DoCmd.RunMacro "Filters.ClearFilter", , ""
-
End
-
End If
-
If (VarType(.txtSearchBox) <> 8) Then
-
End
-
End If
-
DoCmd.SetProperty "cmdSearchGo", acPropertyVisible, "-1"
-
If (.txtSearchBox = "" And .cmdSearchClear.Visible <> 0) Then
-
DoCmd.SetProperty "cmdSearchClear", acPropertyVisible, "0"
-
End
-
DoCmd.SetProperty "iconSearchClear", acPropertyVisible, "0"
-
End If
-
' Handle "'s in search
-
TempVars.Add "strSearch", Replace(.txtSearchBox, """", """""")
-
' Build the Filter for the Asset list
-
If (.Form.Name = "Asset List") Then
-
TempVars.Add "strFilter", "([Status] Like "" * " & [TempVars]![strSearch] & " * "" )"
-
End If
-
If (.Form.Name = "Asset List") Then
-
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Account/Matter] Like "" * " & [TempVars]![strSearch] & " * "" )"
-
End If
-
If (.Form.Name = "Asset List") Then
-
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Container] Like "" * " & [TempVars]![strSearch] & " * "" )"
-
End If
-
If (.Form.Name = "Asset List") Then
-
TempVars.Add "strFilter", TempVars!strFilter & " OR ([NTID] Like "" * " & [TempVars]![strSearch] & " * "" )"
-
End If
-
If (.Form.Name = "Asset List") Then
-
TempVars.Add "strFilter", TempVars!strFilter & " OR ([BP Barcode] Like "" * " & [TempVars]![strSearch] & " * "" )"
-
End If
-
-
' Apply the Filter
-
DoCmd.ApplyFilter "", TempVars!strFilter, ""
-
TempVars.Remove "strFilter"
-
TempVars.Remove "strSearch"
-
DoCmd.SetProperty "cmdSearchClear", acPropertyVisible, "-1"
-
DoCmd.SetProperty "iconSearchClear", acPropertyVisible, "-1"
-
DoCmd.GoToControl "txtSearchBox"
-
DoCmd.SetProperty "cmdSearchGo", acPropertyVisible, "-1"
-
End With
-
-
-
Filters_QuickSearch_Exit:
-
Exit Function
-
-
Filters_QuickSearch_Err:
-
MsgBox Error$
-
Resume Filters_QuickSearch_Exit
-
-
End Function
-
-
1 1318
soapbox3000,
Welcome to Bytes!
First, before we get too far down the "this is really an overcomplexification of avery simple thing" road, I want to ask exactly what it is you are trying to do? It looks like one of the most complicated basic searches I've every seen.
If, you simply want to "search for" something, then, if the form has the navigation buttons displayed (which is a built in feature of Access forms), then just use the search box at the bottom of your form.
But, If you must actually create a filter for the records you are displaying, that is an entirely different story and there is probably a series of additional questions, answers and calrifying details we will need on this one.
Don't give up hope--we just need to know more before we can give you better guidance.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jules |
last post by:
Hi:
I have an Access 97 Search form set up - a couple of combo boxes, a
couple of text fields and a command button. I want the command button
to run an SQL script and then open the results form....
|
by: Guest |
last post by:
I have 2 tables:
1/ English
2/ Deutsch
Which is the best way to make form who is going to scan words from table
English to get meaning ( translation) from table Deutsch.
Of course I need...
|
by: Chris |
last post by:
I need a search form to perform. I have a Form and a subform. The
subform is based off a query and the main form is unbound. The query
runs perfect, however, I have a command button in the main...
|
by: tamoochin |
last post by:
I have a form that registers the user with my website, the form is in farsi language and must use utf-8 standard.
I can store data in MS Access and also read it back with any problems. the...
|
by: Mark |
last post by:
Hi All,
I am creating a music database for a friend and have run into a problem.
Within the ALBUM table, I wanted to store the ARTIST_ID rather than the
ARTIST_NAME. To do this, I intended to have...
|
by: Twisted01 |
last post by:
Hello, I am new here and I hope I have the correct forum to answer my question.
I am creating a website for a friend and they need a "Search Form" so that visitors can search for items on the...
|
by: zandiT |
last post by:
Hello everyone
i have a mainform called frmMain and it has 2 subforms. the frmMain consists of 2 combo boxes. i want to create a search form whereby the user can choose an option in combo1 and in...
|
by: woodey2002 |
last post by:
This problem is driving me crazy.
Hello there,
i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
|
by: f430 |
last post by:
i have been trying to write a search code for a similar database, and i followed all the steps that were provided above, and my code was close to what lightning had but i have added date range in my...
|
by: Breanna |
last post by:
I am very very new to access trying to get a database set up for a new company I work for. So I apologize for the long post. I am not sure what all information is needed to help me and I don't want...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |