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 Replies


ADVERTISEMENT

Getting Results From 7 Query's And Populate Text Labels

May 18, 2005

Ok, i have tried and searched but could not find a good start to a solution for my problem.
I have a calendar form, which shows the dates and under it text labels.
Now whenever something is present in my table (tblKalender) on those dates, i want it to show in the text labels under the correct date.
Now, i have the results through a query, but i dont want to link the query to the form. Only thing that i have trouble with now is getting the information i need to show to those labels. I have written some code (early stages) which i want to show me the results for testing, later on i can fill the fields. I keep getting an error saying not enough parameters, expected is 1.

Can anybody take a look at the code or help me with this?
My query for day one is called qerKal1 and the fields i need to get back are the hour and the task. The query gets it's criteria from the label above that day (lbDag1), which shows the date.

I have this code in a module and when the form is opened it runs the fucntion.

Option Compare Database
Option Explicit

Const strSQLWhere1 As String = "" & _
"SELECT qerKal1.Uur, qerkal1.Taak, qerKal1.Datum " & _
"FROM qerKal1 " & _
"WHERE (((qerKal1.Datum) = [Forms]![frmKalender]![lbDag1].[Caption]));"

Public Function fFillDay1()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Dim strSQL As String
Dim strText As String
Dim strText2 As String

strSQL = strSQLWhere1
Set db = CurrentDb


Set rs = db.OpenRecordset(strSQL, dbOpenForwardOnly)
Do Until rs.EOF
If strText = "" Then
strText = rs!Uur
strText2 = rs!Taak
Else
strText = strText & ", " & rs!Uur
strText2 = strText & "," & rs!Taak
End If
rs.MoveNext
Loop

rs.Close
MsgBox strText & strText2
Set rs = Nothing
Set db = Nothing

End Function

View 5 Replies View Related

Modules & VBA :: Open Form And Unhide Labels?

Mar 5, 2014

I want to be able to open a form and unhide some fields on that form that have been set to hidden, basically if the file paths are wrong it ponts them back to my form where they fill them in , normally these are hidden

Code:
'checks to see if the file paths in the admin screen are ok before allowing to go foward to avoid errors from dowloading data
'get the file path to import data
Dim ImportLoc As String
ImportLoc = DMax("[Path]", "TblsysTransImport")
'Gets the file path to export data
Dim ExportLoc As String
ExportLoc = DMax("[Path]", "TblsysTransExport")

' checks to see if the file path is valid to stop people going further if incorrect or first time use If Dir(ImportLoc, vbDirectory) = "" Or Dir(ExportLoc, vbDirectory) = "" Then MsgBox "sorry but your Import / Export locations dont exsist " & vbNewLine & "These are required so you can download your scan data. " & vbNewLine & "You will now be redirected to enter valid paths"

'open form where they update the paths
DoCmd.OpenForm "Frmadmin", acNormal
'normally hidden
Frmadmin!Line111.Visible = True

i tried to use Frmadmin!Line111.Visible = True

but it says object required (line111 does exist?)

View 3 Replies View Related

Modules & VBA :: Creating One OnClick Event For All Labels On Form

Mar 18, 2014

I would like to make clickable labels on my form, so if the user has any questions about the field, clicking on the label would bring up a message box that would give them more information. I know how to write onclick events one by one for every label, but there are a lot of them, and I feel like there has to be a better way.

I put the label names, and the text I'd like for the message box in a table, and I'd like to have a module that will allow me to click on a label, and have the right text come up.

I've researched ways to do this and have come up with nothing. The farthest I've gotten is an array tied to the form open event that just displays all the message boxes from first to last, one after the other. I believe that's on the right track, but is not a workable solution as is. I need to be able to tie the message box to the actual label the user clicks.

View 4 Replies View Related

Modules & VBA :: Populate A Text Box On Subform Of A Form

Mar 21, 2014

I am trying to populate a txtBox on the SubForm of a Form, Using a Set Value Function = DlookUp function. The DlookUp Function searches for a value in the table and compares it to a value of another txtBox of the subform .The problem is:

-Using the Left Switch on Mouse works fine, txtBox is populated correctly
-Using the Enter Key does not work; it clears the box used for the seaech data and does not populate the txtBox.

I tried placing the procedure in the After Update event and also placing it in the on Enter event to no avail.

View 1 Replies View Related

Modules & VBA :: Double Click Listbox To Populate Form Textbox

Jul 27, 2015

In the past a Teacher would manually create a Form (Student Form) containing Student information, (Name, Gender, Birthdate, Homegroup) as well as additional issues on the student. This would all be saved into a table.

I would like to change this manual process of typing in individually to each text box, therefore, I have been able to run a report from a external program that obtains (Name, Gender, Birthdate, Homegroup). This saves as CSV and I am able to import into a separate table within the database.
This works no problem.

What I have set-up is a form that contains a listbox this contains the Student name and Homegroup from the imported table contents. Again this works fine.

What i would like to do is when a student is selected from the listbox and dbl clicked on, how can i make information (Name, Gender, Birthdate, Homegroup) populate the textboxes in the Student form that the teacher previously used? could this be an update query where the imported table information will then go into the Student form? If so, how can I tell the dbl click of highlighted name is the data i want to populate?

View 1 Replies View Related

Modules & VBA :: Populate Word Fields From Access Continuous Form

Jun 3, 2015

I have a form that I have exported certain fields into a word doc (it is up and running just fine). I created bookmarks in word and put some VBA into my access form, so when I click on 'Create word report' it pops up and automatically populates the record I am on. Here is the tough question,

How to make this work with a continuous form? My main form has several subforms, one being a continuous form. The main form shows one bridge at a time. The sub continuous form shows information for all of the bridges spans (could be anywhere from 1 to 9).

View 4 Replies View Related

Modules & VBA :: Using Unbound Form On Front End Of Database To Populate Backend Tables

Apr 12, 2015

Is there any particular reason I would choose to use

DoCmd.RunSQL "insert into...

Versus

CurrentDb.Execute "insert into.... ??

I am using an unbound form on the front end of my database to populate the backend tables (multiple tables). Some forms only have a few fields, while other forms have about 15 fields with 3-4 tables updating.

I am okay using the DoCmn.RunSQL , but I keeping reading on the forum that others chose CurrentDB.Execute and it has me thinking.

My database is stored on a network drive with only on front end.

View 2 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 :: 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 :: 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 11 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 :: 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 :: 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 :: 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 :: 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 :: Loop Through Subforms / Get All Labels And Change Captions

Jun 26, 2014

I have a form (Form1) and a in it, I have 2 subforms datasheet (Subform1 and Subform2). I have ID, First Name, Last Name in each as headers.

I need to:

1) Find the subforms
2) Loop through the subforms and get all the labels
3) Change the captions

The reason for this is because I need to have the forms bilingual. I do have a function that will translate the caption (called TranslateThisWord). I just cant figure out a way to loop through the subforms and find all the labels.

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

Modules & VBA :: Form Filter And OrderBy Pass To Report

Aug 16, 2014

I am able to filter a data on a continuous form using drop downs and then the following code attached to a cmdbutton to create a report of the filtered data.

Code:
Private Sub Command30_Click()
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "rptconveyorerrors", acViewReport, , strWhere
End Sub

On the same form where I filter the data i can sort it by clicking the headings aswell, however when i generate the report using the above VBA it doesn't take the sort with it and just generates it without the sort.

I am using the following VBA to sort my form

Code:
Me.OrderByOn = True
If Me.OrderBy = "[empname] DESC" Then
Me.OrderBy = "[empname] ASC"
Else
Me.OrderBy = "[empname] DESC"
End If
Me.Refresh

I thought it may be possible to use the following sort of VBA to pass the sort however i cant get it to work:

Code:
Private Sub Command30_Click()
Dim strOrder As String
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then strWhere = Me.Filter
If Me.OrderByOn Then strOrder=Me.OrderByOn

View 1 Replies View Related







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