Modules & VBA :: Resetting Filtered Combo Box
Sep 11, 2013
I am fairly new with Access and VBA and am having troubles with the following. I filter a second combo box "cboTagNumber" with the first combo box "Combo133". The problem is when I clear the first combo box, the second combo box remains filtered. Is there an easy way to clear this?
This is the code:
Private Sub Combo133_AfterUpdate()
Dim strSource As String
strSource = "SELECT ID,[Tag Number] " & _
"FROM [E&I Table] " & _
"WHERE System = '" & Me.Combo133 & "' ORDER BY [Tag Number]"
Me.cboTagNumber.RowSource = strSource
Me.cboTagNumber = vbNullString
End Sub
View Replies
ADVERTISEMENT
Sep 10, 2014
I have the following Event Procedures in a form:
Private Sub PrimaryDisability_Change()
Select Case Me.PrimaryDisability
Case "Other (Specify)"
PrimaryOther.Visible = True
Case Else
[Code] ....
My problem is that when I go to a new record, the fields that I want hidden in the new record unless they meet the criteria are still visible. I have looked all over online and in books to determine the code I use or whatever I need to do to make the field invisible in the new record and only to appear in each record if it meets the criteria.
View 13 Replies
View Related
Jan 28, 2014
Where MS Excel is concerned there is very little I can't do and I am now transferring that skill to MS Access and I'm stumbling on this one.
In Excel I would use the INDIRECT formula within the validation and named range to do this but in Access I'm struggling to get this to work.
I have in table TBL_NL_Structure a list of CLIENT_ID with NL_ACCOUNTS against them i.e.
CLIENT_ID....ACCOUNTS
900001.........4000
900001.........4001
900002.........4003
What I want to be able to do is in a sub form and a combo box named ACCOUNT that looks at the active CLIENT_ID and pulls into to combo box JUST the ACCOUNTS set to that CLIENT_ID example if the CLIENT_ID is 900001 is just brings in ACCOUNTS 4000 & 4001.
I can get the whole list to come in to the combo box but not a filtered list.
View 3 Replies
View Related
Oct 17, 2006
This sounds like a cascading combo box issue but it isn't quite.
I filter my form using 2 unbound combo boxes which can be used in any order, both of which define text strings using case select. These strings are concatenated into a filter text and applied by a routine called in the after update event of either combo. All works well.
My question: How can I show all the filtered records in a third combo box so that users can easily select the record of interest from the filtered set?
I attempted to define SQL for each combination of the 2 comboboxes but it was getting ludicrously complicated so that got the heave ho.
After that, I attempted to use a recordset clone, but I couldn't get this to work:
'Clone record set for combo box rowsource
Dim R As Recordset
Set R = Me.RecordsetClone
R.Bookmark = Me.Bookmark
'Populate combo box with recordset
With Me![cboProjectList]
.RowSource = R
.Requery
End With
Reading the Access help, it seems that a combo box can only be populted via query, table or SQL. Is there any way of using a cloned recordset or the me.filter to show the filtered form records in a combo or list box?
I will be very grateful for any pointers.
View 8 Replies
View Related
May 8, 2013
Basically what I would like to do is create a Combo Box with each month of the year available to select. When I click on a specific month, I want it to pop open a Report based on my table that is filtered by the month I selected. I have a Date column already created in my base table to be my filtering device.
I've already learned how to use query's and reports a bit. I have a Command Button on my form that launches a report based on a query that only shows data for the current year. Likewise, I created one that only shows data for things with a specific item code using a [Which Item Code?] criteria in my query. So in theory, I could do this by creating 12 different buttons, 12 different query's, and 12 different reports. That seems like overkill though and it would seem there has to be an easier way to do that simply by using a combo box to select the month you want to filter.
View 14 Replies
View Related
Mar 7, 2014
I have a form with subform (datasheet) .
On my subform i have one field which shows the
productId ( which is filtered from combo boxes on main form) .
productId contains two columns
1 bound column(id) ( hidden with width 0 )
2 column (desription) ( shown with width 2 )
Now after entering the data when i come back to the form again . It hides the data from the productId field on subform , because data in combo box (on main form) doesn't match. Although the row is showing up , only the text in field (productId) is hidden.
Now when i change data in combo box on main form to match the ProductId , then the productId field text shows again. after changing combo box it hides . What i need is the existing data should not hide when i change the combo box selection.
see pic 1 where product matches and pic 2 where not. please note i am using master child relationship on the form/subform.
View 14 Replies
View Related
Aug 23, 2013
I'm trying to make a filtered search form using "*" as a wildcard default value in combo boxes, this works for all the text fields except for the account number field (Numeric primary key). After quite a bit of reading up and searching, I tried using the following as the row source;
SELECT customers.ACCOUNT_NO, customers.CUSTOMER FROM customers; UNION SELECT "*", "All" From Customers;
But am still getting "#Error" in the combo box.
View 2 Replies
View Related
Jan 30, 2014
I have a query that is filtered on a form (Forms!qRosterReport!SessionID) that I need to export to XML. I can export the query unfiltered but get an error with the filtered export. I am ok with Macros but very limited with VBA.
View 3 Replies
View Related
Oct 7, 2013
I have a split form with graphs in the upper design section and the table of the data that the graphs represent in the data view underneath. I would like to make the graphs dynamic with the data from the forms if the data is filtered in design view.
I know how to get the filter from the data view by using the .filter and I would like to use that as part of an SQL statement in my Rowsource for the graphs to dynamically change the graphs when a filter is used. My problem is the data is returned with .filter function returns with quotation marks (example below), and because I'm wanting to use that data in a string to change my rowsource the quotes need to be replaced with an apostrophe. How can I change the quotes to an apostrophe, or is there a better way to "filter" a graph?
Example:
Returned from .filter
([FrmTable].[CurrentABCS]="A")
What I need:
([FrmTable].[CurrentABCS]='A')
View 2 Replies
View Related
Apr 10, 2014
I have made a form with different records now my goal is to filter those records and export the details of those records to excisting Word files.
So for instance:
Record filtered on:
Title: TrainingsSharepoint
Location: London
Than it wil export the details to --> Doc1.docx
Or
Title: TrainingSale
Location: Berlin
Than it will export the details to --> Doc2.docx
And so one...
The Word files already have some text in them so i want to set up variables to insert the details in the right place.
View 1 Replies
View Related
Dec 17, 2013
In my Access adp, when I open a certain form (frmVertebrates), the databinding occurs in the Load event for the form, for various reasons. I have not specified any datasource in the form's design view.
Databinding for frmVertebrates:
Code:
Me.Form.RecordSource = "select * from dbo.vertebrates where catalogID=3"
This works great when just opening the form. However, when opening with a filter from a button on another form it won't work, the form displays all records.
Button code:
DoCmd.OpenForm frmVertebrates, , , "vertID=123"
Obviously, this makes sense, since the record source is explicitly set in the Load event.
Is there a way to capture the filter "vertID=123" so it can be added to the Form.RecordSource sql?
When breaking in the Load-code and watching the 'form' variable, I can't spot the filter condition anywhere...
View 4 Replies
View Related
Apr 7, 2014
VBA code to filter the table :
Code:
Dim db As Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim flnm As String
Dim appXl As Excel.Application
Dim bookXl As Excel.Workbook
Const wrksheetName As String = "Welder Performance Overall"
[Code] ....
if i use DoCmd.OutputTo function, its export the whole table to excel. how can i filter this table ?
Environment : Ms.Access 2010
View 12 Replies
View Related
Aug 26, 2014
I was having a wee look around the Export Threads and came across the following VBA Code I thought would be handy to export a Query to a new Excel workbook, and although it did export to excel, it didn't filter the query to show only the things I was wanting. Now I've managed to have it not work at all!
Code:
Private Sub cmdOK_Click()
'Step 1: Declare your variables
Dim MyDatabase As DAO.Database
Dim MyQueryDef As DAO.QueryDef
Dim MyRecordset As DAO.Recordset
Dim strSQL As String
Dim i As Integer
[code]...
View 1 Replies
View Related
Oct 20, 2014
I have an Excel file with a name range "DBIAS" which identifies all database data.
Then I have an Access file with a form to import that database (better, that named range) into an Access table. While importing, I have to filter some records or grouping by some field.
I cannot run correctly a VBA code to get data (filtered and/or grouped) from that name range and save those records to an existing or a brand new table.
I could get those data as DAO.recordset and printed out with "Debug.print" on immediate window, but I cannot complete the final step: writing those records to a table.
View 3 Replies
View Related
Jul 8, 2015
I am currently working on a form that exports a query that changes after a user set filter is applied, and am able to get the filter to apply and the query to export. The problem I am having is that the worksheet that the query is copied into retains all previous data, and if the earlier query export included more records, they remain as they were, is there any way of getting them to be blank.
I want to export my query onto a worksheet that has current data, need to delete current data or delete worksheet so that only the selected data is shown.
My code currently is:
Private Sub Command67_Click()
Dim strWhere As String
Dim strFile As String
Const strcStub = "SELECT NomT.shkFirstName, NomT.shkSurName, NomT.shkCompanyName, NomT.shkAdd1, NomT.shkAdd2, NomT.shkPostCode, NomT.shkRegion, NomT.shkCountry, NomT.shkAdd3" & " FROM NomT" & vbCrLf
With Me.FilterSub.Form
[Code] .....
View 4 Replies
View Related
May 3, 2006
Hi there gurus...
I have made a form with various text-boxes, radio-buttons and other controls on it. The form is not bound to a table or query: I'm just using the form as a data-gathering device for my VBA code. After the user has entered the data I want to use a button to reset the boxes and controls to the way they were when the form was openened, ie as though the user closed the form down and re-opened it again. I know I can do this by resetting the .value of each control back to its default, but there's about 30 controls to reset! Is there not something like "forms!main.reset" that just resets all the controls a form back to their default values, clears out text boxes, etc etc as though the user has closed & reopened the form?
Ta
John
View 12 Replies
View Related
Oct 11, 2005
here the scenario:
i have a page displaying all the contents of my table with the first field a autonumber as a button on the page.
when i click the button, (Ex. number 15) it brings me to another page where i can delete the clicked entry.
after deleting, i go back to the viewing page, because i deleted number 15, it now shows, 1,2,-----14,16,--- so on so forth.
how can i reset the autonumber so that when i go back to the viewing page the numbers are in order again?
hope u got my point. thanks for any help u can give.
View 3 Replies
View Related
Sep 15, 2005
could someone please tell how i can reset an autonumber field to start from 1.
basically i have created a table and carried out a number of test with useless data. now that i have the table set up the way i want it and i have tested the queries etc i want to delete all the current data in the table and begin filling it with correct data. however i want my primary id to start from 1 which at the moment it doesn't because i have just deleted 50 records.
thanks in advance
View 2 Replies
View Related
Mar 5, 2006
I have a quick question. I have a table that has a field with a seed identity with an increment of 1. Right now I have records in the table ranging from 1965001 - 1988704. Every so often the oldest records are archived off to another database. However, I have just been informed that the records from this table can not exceed 2000000 in the seed identity field. Ideally, I would like to just go into the table design view and change the seed identity to 1000001 and leave all of the existing records as they are, knowing that it will be years before it causes an issue. I've tried this in the lab and it didn't work, the seed identity issued was always 1 higher than the highest record in the table.
My plan B is to export all of the records out of the table, change the seed identity, and append the records issuing a new identity. The problem with this is that the seed identity is referenced in other tables, which would have to updated.
The easiest solution for me would be to be able to just change the seed identity and start issuing new seed identities, leaving the existing records alone.
I am no Access expert so please forgive me if my approach is way off.
View 3 Replies
View Related
Jan 4, 2007
I cleared a table of records and need to restart (at one) the autonumber field. I used the instructions found on on-line help but they will not reset the field back to one. Any one have a solution. I have even deleted the field and created a new one with the same name and it started with the same value it would hav used before I deleted any records.
View 3 Replies
View Related
Oct 17, 2006
Trying to calculate a YTD running sum by Month where the cumulative amount resets the next year as below.
AYearAmonthSumOfFreightRunTot FDate
19951$2,798.59$2,798.59Jan
19952$1,675.06$4,473.65Feb
19953$2,165.37$6,639.02Mar
19954$1,661.66$8,300.68Apr
19955$3,166.25$11,466.93May
19956$3,461.40$14,928.33Jun
19957$1,852.65$16,780.98Jul
19958$2,458.72$20,527.88Aug
19959$3,078.27$25,003.32Sep
199510$3,237.05$29,363.85Oct
199511$3,934.70$34,708.77Nov
199512$2,019.68$38,990.68Dec
19961$3,757.96$3,757.96Jan
19962$5,395.28$9,153.24Feb
19963$4,341.10$13,494.34Mar
19964$5,379.02$18,873.36Apr
Here's my practice SQL (in NorthWinds.mdb
SELECT DatePart("yyyy",[OrderDate]) AS AYear, DatePart("m",[OrderDate]) AS Amonth, Sum(Orders.Freight) AS SumOfFreight, Val(DSum("Freight","Orders","DatePart('m',[OrderDate])<=" & [Amonth] & " And DatePart('yyyy',[OrderDate])<=" & [Ayear] & " ")) AS RunTot, Format([OrderDate],"mmm") AS FDate
FROM Orders
WHERE (((DatePart("yyyy",[OrderDate])) Between 1995 And 1996))
GROUP BY DatePart("yyyy",[OrderDate]), DatePart("m",[OrderDate]), Format([OrderDate],"mmm")
ORDER BY DatePart("yyyy",[OrderDate]), DatePart("m",[OrderDate]), Format([OrderDate],"mmm");
Here's what I get:
AYearAmonthSumOfFreightRunTotFDate
19951$2,798.59$2,798.59Jan
19952$1,675.06$4,473.65Feb
19953$2,165.37$6,639.02Mar
19954$1,661.66$8,300.68Apr
19955$3,166.25$11,466.93May
19956$3,461.40$14,928.33Jun
19957$1,852.65$16,780.98Jul
19958$2,458.72$20,527.88Aug
19959$3,078.27$25,003.32Sep
199510$3,237.05$29,363.85Oct
199511$3,934.70$34,708.77Nov
199512$2,019.68$38,990.68Dec
19961$3,757.96$6,556.55Jan
19962$5,395.28$13,626.89Feb
19963$4,341.10$20,133.36Mar
19964$5,379.02$27,174.04Apr
19965$6,481.29$36,821.58May
19966$597.36 $40,880.34Jun
Anyone have an idea for correcting this problem?
Thanks in advance,
Barb
View 3 Replies
View Related
Feb 7, 2005
I have a Form/subform that is used to allow editing of a user selected record from a table called personnel. When the form/subform is first opened, all text boxes are blank. The user selects the desired record from a combo box that uses a dropdown list to display all records of the table. When a record is selected, the contents of that record are displayed in the subform in which the user can then edit/modify. The user then clicks on a "save button" which then saves the record.
I want to use a msgbox that will notify the user that he has just updated a record and ask if he/she would like to update another record. If the answer is NO, then close form/subform. If answer is YES, I would like to clear the combo box and the subform text boxes. then the user can them start the process over by selecting the desired record from the combo box.
When I placed the msgbox coding into the "save" button's on click property, the NO portion worked fine. However, when YES is selected, the combo box would clear but the subform texboxes still show the previous record data (does not clear).
Can anyone provide some assistance?
Here is the code for the main form:
Sub SetFilter()
Dim LSQL As String
LSQL = "select * from personnel"
LSQL = LSQL & " where last = '" & cboSelected & "'"
Form_Editpersonnel_sub.RecordSource = LSQL
End Sub
Private Sub cboSelected_AfterUpdate()
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
Private Sub Form_Open(Cancel As Integer)
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
Here is the code for the subform "save" button:
Private Sub SAVE_Click()
On Error GoTo Err_SAVE_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.close
If MsgBox("You have updated information on a Detachment Member. Do you wish to update another member?", vbExclamation + vbYesNo + vbDefaultButton2, "WARNING") = vbNo Then
DoCmd.OpenForm "PERSONNEL MANAGEMENT"
Else
DoCmd.close
DoCmd.OpenForm "Edit personnel"
End If
Exit_SAVE_Click:
Exit Sub
Err_SAVE_Click:
MsgBox Err.Description
Resume Exit_SAVE_Click
End Sub
View 2 Replies
View Related
Dec 1, 2006
I have a number of tables (I know someone is going to say you don't need a primary field for these tables but I want to use one) that are basically lookup tables for combo boxes. Generally I use an autonumber to identify the ID of each record. There are occasions when all the records need to be changed (i.e. delete all old records) - does anyone know how I can programmatically (or otherwise) reset the autonumber from the last used back to "1" if all records from the table are deleted.
Beeky
View 4 Replies
View Related
Jul 3, 2007
I'm redeveloping a DB for a new project, so have removed all previous records from relevant tables (to start a-fresh)
One snub, the ID fields in the tables are auto increasing from where they left off, rather than from 1
If anyone knows how to reset the auto counters, it would be very much appreciated
Thanks in advance
View 4 Replies
View Related
Feb 9, 2005
I have five Option Groups on my form. I was running into a problem where after selecting options for one record and then moving onto the next record, the previous options would stay selected for the new record.
I "thought" I had found a solution by setting the Option Group values to Null in the OnCurrent event of the form, but I found a problem in that when going back to a previous record, it is nulling out the previously selected options. Doh!
Any ideas on how to get around this problem? I want to be able to go from one record to the next without carried over options, but I also want to be able to go back to already entered records without having them nulled out.
View 3 Replies
View Related
Mar 2, 2005
I have a couple of fields on my form (Resolution Type, Date Closed) that I want to display only if the Status field has Closed as its selection for each record. I initially set the Visible parameter of both the type and closed fields to False and I reset them to visible by checking for open/closed with an afterupdate event. This works great for the first record but...subsequent entries display those 2, regardless.
I know just enough regarding events to struggle my way through on some things but more advanced field, record level and form level events are beyond my experience level.
Can anybody offer any advice on how to get those two fields to toggle visible/invisible when scrolling through the records?
With that said, does anyone have a link to a post/website referencing this subject?
Thanks in advance,
Mike
View 1 Replies
View Related