Modules & VBA :: Adding Filter When Open Second Form

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 Replies


ADVERTISEMENT

Modules & VBA :: Filter Not Triggering On Form Open

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

Modules & VBA :: Filter Records - Adding Unbound Date Listbox To Filter String

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

Modules & VBA :: Open Report - Filter Month And Year

Feb 25, 2015

I have vba code

PHP Code:

    DoCmd.OpenReport "MonthlyData2", acPreview, , " YEAR(CourseDate) = '" & Me.txtCourseDateMonth & "' " 

this works sucessfuly how can I add the following to the code so it filters month and year?

PHP Code:

'" MONTH(CourseDate) = '" & Me.txtCourseDateYear & "' " 

View 5 Replies View Related

Modules & VBA :: Setting Filter Property Via On Open Event Of A Report

Dec 15, 2014

I have a report, on a control tab, on a main form.

On the form are two buttons: one to show all items, and one to filter them based on a boolean field called showitem.

The buttons work with the code below.

What I want to do but cannot seem to figure out is to have the report default to no filter.

The bound query has no criteria.

I'm trying to set the filter property via the on open or on load event and even if I isolate the report, cannot seem to reach it.

Code:
Private Sub b_hide_items_Click()
Me.Profile_Timeline_wNotes_subreport.Report.Filter = "timeline.showItem <> 1"
Me.Profile_Timeline_wNotes_subreport.Report.FilterOn = True
Me.Profile_Timeline_wNotes_subreport.Requery
End Sub

Private Sub b_show_all_Click()
Me.Profile_Timeline_wNotes_subreport.Report.Filter = "timeline.showItem = 0"
Me.Profile_Timeline_wNotes_subreport.Report.FilterOn = False
Me.Profile_Timeline_wNotes_subreport.Requery
End Sub

View 14 Replies View Related

Open Form With Filter

Sep 8, 2005

I have a simple bit of code below but I need something added. All the code is doing is opening a form and filtering on a combo box value. It opens all cases where the status is open but if there are no open cases it takes me to a new record, how do I get my code to recognise that there are no cases and display a message box for me instead and then close the form?

Private Sub open_Click()

Dim stDocname As String

stDocname = "frmMain"

DoCmd.OpenForm stDocname
DoCmd.ApplyFilter , "Status ='Open"

End Sub

View 3 Replies View Related

Open Form Not Adding Record And Use An Add Button On Form

Aug 2, 2006

I have a database with three tables

table 1 (form1)
reference (PK) auto number

table 2 (form2)
Reference (fK)
workbook reference (PK) auto number

Table 3 (sub form within in form2)
Reference (FK)
workbook reference (fK)
data Reference (pk) auto number

Each table is a form that is linked via the keys. On form 1 i have a button that is to open the form2, which it does but every time i open the form a new record is added. Why and how do i prevent this.

Then what i want to do is add a button for a new form on table 2 form but use the same reference as the record as presently displayed. How do i add new record using the same Reference but new workbook Reference?

Thanks is advance

View 1 Replies View Related

Open Form, Link Criteria, Filter, Cant Set Default Value To A Control.. Why?

Dec 15, 2006

Private Sub btncard_Click()
Dim stLinkCriteria As String
DoCmd.RunCommand acCmdSaveRecord
stLinkCriteria = "[jobref]=" & "'" & Me![jobref] & "'"
DoCmd.Close
DoCmd.OpenForm "k_job_card", , , stLinkCriteria
End Sub

this button code opens the k_job_card form.

the form opens and says 'Record 1 of 1, (Filtered)

i have a control on the form that opens.. and i am simply trying to assign a default value to that control..

it is a textbox.. for my jobtype field (text datatype)..

is there any particular reason why i cannot assign a default value to a control if it has been placed on a form that has been opened using a form filter?

this is how the Form Data tab is set at the moment..

View 3 Replies View Related

Reports :: Using Command Button In A Form To Filter And Open A Report?

Jun 26, 2014

I'm trying to use a command button in a form to filter and open a report. I am able to get it to open the report, but I cannot get it to filter the report based on a combobox in the form. I've tried every combination of code I could think of and find. Here is what I currently have:

Code:
Private Sub FilterReport_Click()
DoCmd.OpenReport "Report", acViewReport, "First Name='" & Me.FName & "'"
End Sub

Code:
Option Compare Database
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = Me.FName
End Sub

"FilterReport" = Form Button
"Report" = Report
"First Name" = Report Field
"FName" = Form Combo Box

View 14 Replies View Related

Modules & VBA :: Filter The Form Records With It?

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

Modules & VBA :: List Box Form Filter?

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

Modules & VBA :: Adding Controls To Form And Saving Modified Form

Dec 3, 2013

I am trying to open a form in design mode and add controls, this i have done. I am doing this all in a class, and am having trouble saving the modified form.

I have tried using the following, both produce errors

Code:

DoCmd.Save acForm, "tmpQueryDes"
DoCmd.Close acForm, "tmpQueryDes", acSaveYes

View 3 Replies View Related

Forms :: Open A Form For Adding Child Record Related To Highlighted Record In Subform

Oct 2, 2013

Is it possible to open a form to add a child record related to the highlighted record in the subform?

View 2 Replies View Related

Modules & VBA :: Filter Not Working In Navigation Form

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

Modules & VBA :: Form Filter And Exclude With Check Box?

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

Modules & VBA :: Applying Filter In Form With 2 Variables

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

Modules & VBA :: Using Combo Box To Filter Records From A Form?

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

Modules & VBA :: Setting Filter On A Form With Variables

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

Modules & VBA :: Filter By Form With Multiple Options

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

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 1 Replies View Related

Modules & VBA :: Using Filter On Form To Populate Labels

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

Modules & VBA :: Filter A Report Via Unbound Form

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

Modules & VBA :: 2 Combo Box On A Form - Apply Filter?

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

Modules & VBA :: Adding To A Access Form

Dec 19, 2014

i have a form in access 2010 and i have a text box called USLINE and other one called USOFlag and i want the USLINE field to do like if it's is not null then it is a Y else N i try to do it in the LostFocus function but i cant get it to work.Here is the the code that i used:

Private Sub USLine9_LostFocus()
If IsNull(USLine9.Value) Then
USOFlag.Value = "Y"
Else
USOFlag.Value = "N"
End If
End Sub

View 12 Replies View Related

Modules & VBA :: Navigation Form - Filter On Subform Not Working

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

Modules & VBA :: Can Filter Child Subform From Parent Form?

Jun 11, 2013

I am updating an existing database and I have a parent/child form and I want to filter the subform for the current parent form record? The two forms are linked together by woWorkOrderID/deWorkOrderID.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved