Modules & VBA :: How To Save A Form Filter To Reapply Later
May 11, 2015
I've taken over the running of the front end of an access database. It's old and antiquated, but is owned by our client and they don't want to move away from it. (it's probably worth pointing out I'm new to VBA, and not a programmer).
Most of what the users want in stored in one table which has a front end form. The users spend a lot of time setting up filters on the form (approx 20 different boxes to filter on).
I've been asked to add in a way of saving these filters so they can be recalled, and I'm wondering if there is an easy way of doing this?
I know that when a filter is set on a form that this creates a temporary query. So my thinking was to somehow save the SQL from the temp query to a new table (user can set a name for the filter from a subform when saving).
I was then hoping I could populate the sub form with a combobox (filtered on the logged in user) and display the appropriate items from the table.
The user could then select an item from the list, press apply, and the form would then be filtered using the previously saved query.
View Replies
ADVERTISEMENT
Oct 16, 2014
I wish to export a report to excel, but I wish to prompt the user to be able to choose where to save the file at. How can I have the "Save As" dialog box pop up, with the filter set to "*.xls"?
View 2 Replies
View Related
Feb 12, 2014
So I have this relatively simple problem: I need to create a button that once clicked will open the Save As dialog box and allow the user to save a copy of the current database where he wishes. The filename should contain todays date in DDMM format along with some pre-set text e.g. DDMM PresetText.
I am using Access 2010.
View 2 Replies
View Related
Jan 10, 2014
I have a few selected reports on an Access 2007 database that users can run. Is there a way for users to view the report, save as a PDF and automatically save a copy to a shared drive by modules/vba coding as an On Click event procedure?
View 4 Replies
View Related
Jan 17, 2014
I'm using: DoCmd.OutputTo acOutputForm, "Frm_EL_PL_Bulk_Send", acFormatPDF, outputFileName1...To save a form as a PDF. The issue is, it saves all the records in that set in continuous form, and I'm trying to get it to only save the record its on.
View 3 Replies
View Related
Apr 22, 2014
i have a form with subform in it, and when i press the save button in the main form it saves only the records in it but it wont save the records in the subform
i found on microsoft this code
DoCmd.Save acForm, "New Employees Form"
how can i use it to save both the main form and subform together
View 3 Replies
View Related
Oct 24, 2013
i got a form with three normal fields where i add data i then have two auto number fields i.e. SupplierID and PersonID the supplierID works fine, i can add a new record and click save and it will save the data in the suppliers table.The problem is with my PersonID field, i need it to retrieve the data from my subform and firstly display in the field on my main form and secondly, when i click save it should save save the number that is displayed into my Suppliers table.
View 2 Replies
View Related
Jan 21, 2015
I put the formula in the Text box field in the control source in the property's tool box and i don't know if it will save that calculation to the table. I was wondering if i can do VBA code to save the the calculation in the table.I have a field called CA Weigt and i put the formula in there as =[Weight] * 0.4536 and it works. How would i put it in a vba code.
View 7 Replies
View Related
Apr 22, 2015
I have a MainForm. Using a button on the MainForm i open an PopUp form which I enter values.
I want to save the value of a field (text), close the PopUp form. Then use the Saved value in the MainForm to find a record.
So far I have this but not working:
Code:
TempVars.Add "company", Me.CompanyName.Value
If Me.Dirty = True Then
Me.Undo
End If
DoCmd.Close
DoCmd.OpenForm "MainForm"
DoCmd.Requery
DoCmd.FindRecord Forms![MainForm]![CompanyName] = TempVars("company")
DoCmd.GoToControl "Combo48"
View 5 Replies
View Related
Jun 15, 2014
I have a button that when clicked moves a piece of data to a subform. I have put the whole sequence below. The trouble I am having is :
- The event will not happen until the form is saved. I think this is because fkTaskID is a new record (auto) number which hasn't generated yet.
- If I force the form to save it does work but then I get an error on the INSERT command when not all required fields of the form are complete (see sample in second part below).
Is there a way to save the record and maintain the integrity of the form input - and still have this code work?
BUTTON CODE
==========
Private Sub BTNAddReasonRw_Click()
Dim dIndex As Long
DoCmd.SetWarnings False
For dIndex = 0 To Me.LISTReworkReasonsUnselected.ListCount - 1
[Code] ......
View 1 Replies
View Related
Feb 9, 2008
Hi,
Iam new to access need some help to solve this, iam unable to save filtered condition as a query in access. when i click on file > save as option i have only three list i can choose from Form,Report and data access page . I want to save the condition as a query which iam unable to do. Any help in this would be appreciated
Thank u
View 1 Replies
View Related
Sep 12, 2014
vba code for filtering the records of the form made out of a table. The form contains combos that contain the lists of unique records in several colomns of the source tale. So i need to filter the records of the form using the combination of the values of that combos. But can't even apply a single filter using this code:
Me.Filter = "Business = " & list59.Value
Me.FilterOn = True
"Business" is the name of the column in the source table, and the "list59" is the name of the combo which contains the unique records of the "Business"
the code takes place as a button "apply" is pressed
View 4 Replies
View Related
Feb 12, 2014
I want to be able to show all records from tblRecords where, The [tblUser][PositionID] = The Value selected on the list box.The problem being I don't know how to do this with them all being on seperate tables and linked via relationships. I.e. [tblRecords] only holds the UserID, [tblUser] has the PositionID.
I also need this value to keep building towards my filter string, i.e. I can select this position ID and records from within the past 4 days.I've attached pics of the form and relationships.
Here is my current code:
Code:
Option Compare Database
Option Explicit
Private Sub cmdReset_Click()
'Purpose: Clear all the search boxes in the Form Header, and show all records again.
Dim ctl As Control
[code]....
View 6 Replies
View Related
Jul 20, 2014
I inherited this quote and trying to enhance it but having problem.
The filter in navigation form is not working but it is on its own form, the filter is working without problem.
View 5 Replies
View Related
Aug 14, 2014
I have the following code which builds a filter on my form which i can then generate a report from.
However id like to add a check box to exclude rather than include a certain [Error_Type] which is "Wrong Batch" and im not sure how id do it..
the vba i have so far is as follows
Code:
Private Sub cmdFilterConvErrors_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "#mm/dd/yy#"
If Not IsNull(Me.txtqccheckby) Then
strWhere = strWhere & "([Error_QC_By] = """ & Me.txtqccheckby & """) AND "
[code].....
View 1 Replies
View Related
Jun 6, 2013
I am fairly new to VBA and am trying to apply a filter within a form so that agent records can be filtered based on an agent's name (so that they can only see information that refers to them).
I also want a record to be removed when it has been completed (when this habbens a date completed field will populated) however I do want to see those completed records that refer to the agent that have been completed today.
Here is my code. The 2 filters work on their own howver when I put them together I get a mismatch error.
If Me.txtRole = "Agent" Then
DateCompletedFilter = "(DATECOMPLETED Is Null) Or (DATECOMPLETED = Date())"
AgentFilter = "CASEOWNER ='" & Me.txtName & "'"
DoCmd.ApplyFilter , AgentFilter And DateCompletedFilter
Exit Sub
End If
View 13 Replies
View Related
Oct 1, 2014
I am using combo box to filter records from a form. The data source for the form is from a query.
I use the combo box within the query to filter the data, I would like the form to refresh/ run the query again every time a new selection is made from the combo box.
View 2 Replies
View Related
Aug 26, 2014
I am trying to set a filter on a form with VBA using variables and having no success at all. The code I tried last, which seemed to be "close, but no cigar", was:
Code:
Dim sFilterValue As String
Me.FilterOn = False
sBiller = Me.txtbiller.Value
sLastSource = Me.txtbiller.ControlSource
sLastSource = "[" & sLastSource & "]"
sFilterValue = sLastSource & "=" & sBiller
Me.Filter = sFilterValue
Me.FilterOn = True
sLastSource and sBiller are global variables. When I debug this code the sFilterValue is exactly what I would plug in manually and the Me.Filter shows up as "[Field Name] = Filter Value". But it crashes on Me.Filter = sFilterValue. I have tried all sorts of combinations but nothing I've tried works. What is the proper syntax for using variables as filters?
View 2 Replies
View Related
Aug 28, 2013
I tried Link model "bank_pay" with the main_form << to add details of information >> by "pay_num" in main_form and "num" in "bank_pay" by filter >>
Code:
Private Sub pay_type_AfterUpdate()
Select Case pay_type
Case Is = "1"
DoCmd.OpenForm "bank_pay", acNormal, "", """[forms]![main_many_1]![main_many_sub]![pay_num]="" & [num]", , acNormal
End Select
End Sub
no result :
file in attachments >>
View 11 Replies
View Related
Jul 23, 2014
I am using Select Case to filter a form on open and it works fine when I have this:
Code:
Case Is = 2
Forms![Open Opportunities List].Form.Filter = "[Employee] = 4"
Forms![Open Opportunities List].Form.FilterOn = True
But if I want the form to open filtering multiple employee records, like this:
Code:
Case Is = 6
Forms![Open Opportunities List].Form.Filter = "[Employee] = 2 & " And 9 & " And 10 & " And 11
Forms![Open Opportunities List].Form.FilterOn = True
I get a type mismatch error and I am stumped as to why and how to overcome.
View 14 Replies
View Related
Oct 28, 2014
I'm trying to add onto the open report command but having problems.I'm using the filter on a form to populate labels
Code:
DoCmd.OpenReport "Labels_Contacts", acViewPreview, , Me.Filter & "and [Mail] = 'Yes'"
and Access doesn't like this.I'm getting a 3075 error "Syntax error (missing operator) in query expression 'and [Mail] = Yes'.What is the correct syntax for this?
View 8 Replies
View Related
Apr 22, 2014
When I have a value in "WorkCenter" everything works great and graph looks fine. When I leave blank in order to see all records, I get a blank graph.
Here's the code:
Private Sub Open_Downtime_Graph_Click()
Dim strCriteria As String
If IsNull(Me.WorkCenter) Then
strCriteria = "[WorkCenter] Like '*'"
[Code] .....
View 7 Replies
View Related
Jul 28, 2015
we have gotten in to a routine of copying, pasting and bastardizing old databases instead of creating new ones from scratch - and we've had a problem recently where we've started off with one master database back in 2011, which has then been the base for practically every single major DB we've created ever since.So this month we've copied and pasted (again) and started adding new features to what's already there, and the thing has corrupted. I've copied and pasted the same version three times and added all the new bits, and the same thing has happened every time.
So this time I've copied and pasted and tried my best to clean up, get rid of the dead weight and (where necessary) create completely new objects, split into FE and BE versions etc, and I've reduced the overall weight of the DB by about 50%.Due to time constraints I now need to crack on and get this thing working again and, for the most part, it does - but now I'm having trouble carrying the filter over from the OnClick Event of a form button to the next form it's opening.
We're using the DB to record attendees at an Event we're running later in the year. This is the code that I'm running from the OnClick Event of the button on Form1:
Code:
Private Sub btnBkg_Click()
On Error GoTo Err_btnBkg_Click
Dim stDocName, vFilt As String
Dim vBkgRef As Long
Dim vContactID As Long
[code]....
You can see I've tried to use vFilt instead of the actual code for frmBooking's Where Condition, but for some reason it does not carry over to the form whichever way I try - when I open the immediate window and type ?vFilt it returns a blank entry. Not sure how to show the 'Where Condition' in the Immediate Window?Before Update, Open and Activate of frmBooking, but I'm hoping that the problem lies with what I've posted up here, as I don't want to get into posting the frmBooking code...
It may be worth noting that the button resides in the Header of a continuous form, with conditional formatting that changes the button caption depending on whether there is a value in the BkgRef text box of the record that has the focus.
View 3 Replies
View Related
Sep 25, 2013
I Have 2 combo box on a form: Product_Type (6 values) and Product_Name (30 values and each belongs to a type), I want to narrow down the Product_Name to related Product_type whenever I select a type in the first field. Is there anyway to do this?
View 2 Replies
View Related
Feb 10, 2014
I'm trying to hash two scripts I've found into 1 functioning filter, however I'm still relatively new to vba and can't figure out how to get this working.
I'm trying to use Allen Browne's Search Criteria:
with another snippete of code I found here:
Code:
'Purpose: This module illustrates how to create a search form, _
where the user can enter as many or few criteria as they wish, _
and results are shown one per line.
[Code]....
It's the date part I'm having trouble with, the rest of the search criteria work fine without the date, but I can't get it working when I try to modify and merge the date sections of each code.
Also I'm using a listbox for the "Yesterday";"Last 4 days";"Last 9 days" and not a combo box.
View 2 Replies
View Related
May 12, 2015
I have a navigation form which has two subforms on it (ie 2 tabs linking to different forms). I have got aq filter working for one of the forms but not on the other. This is using
If IsNull(Me.txtoperationscontract) Then
MsgBox "Please type a contract number into the textbox!", vbInformation + vbOKOnly, "Incorrect Details"
Else
Me.OperationsSubform.Form.Filter = "[Contract]='" & Me.txtoperationscontract.Value & "' "
Me.OperationsSubform.Form.FilterOn = True
End If
The problem is that it does not work on subform B because the Contract field does not exist.
View 6 Replies
View Related