I am trying to get the OrderBy to recognize wildcards (or to that effect). A scenario would be I would have more than one name in a field, EX: Name2, 4, 6. How do I use wildcards in the OrderBy and they are recognized.
ORDER BY (Table.Field)="Name1", (Table.Field)="Name2", (Table.Field)="Name3", (Table.Field)="Name4", (Table.Field)="Name5", (Table.Field)="Name6", (Table.Field)="Name7", (Table.Field)="Name8";
Hi, I have a list box based on a quite a complex query. I would like give the user the option to dynamically sort the list box.
How can I refer to my listbox's SQL rowsource and add a sort order using VB? i.e. Private Sub CmdButtonSortByName_Click Dim strSQL as String strSQL = me.listbox.rowsource & "ORDER BY FieldName;" me.listbox.rowsource = strSQL
I am aware of how I could do this if my SQL was in VB i.e.:
Dim strSQL as String Dim strSortOrder as String Dim optSort as Integer
Select Case optSort.Value Case 1 strSortOrder = "ORDER BY LastName;" Case 2 strSortOrder = "ORDER BY FirstName;" End Select
In my db I have a report that I would like to sort by different fields. I tried coding this using option buttons, a command button, and the "Case" statement. While putting in the OrderBy portion of the code I keep getting errors in relation to the syntax. I'm not sure how long I worked with it and got absolutely nowhere. Can someone clue me in please? Here's my code:
Private Sub Command14_Click() Select Case Me!Frame5.Value Case 1 'Sort by Military Occupational Specialty (MOS) ascending DoCmd.OpenReport ("Report1") OrderBy MOS
Case 2 'Sort by Military Occupational Specialty (MOS) descending DoCmd.OpenReport ("Report1") OrderBy MOS, DESC
Case Else MsgBox ("Please select an option before attempting to open the report.")
Hi all, Found a weird problem when editing records in continuous form view (and datasheet view) when a particular memo field is being used by OrderBy to sort the data. When i have just created a new record and tab to the next record, the record i was just in jumps to the top of the records, but in its place is an exact copy of the record above. Very confusing, and looks like a redraw bug but it happens on all PCs.
What happens is ... (letters relate to records going down the screen)
A B C D ....new record being entered then <TAB> and ...
D ....has jumped up here A B C C ....duplicate of C - but duplicate record never created in the table E ....new record
When i quit the form and come back in, everything is ok
As far as i know, OrderBy only takes effect if you refresh the form (which i'm not doing). It works fine if i take off OrderBy, or if i use another field with OrderBy. So is there some problem using OrderBy with a memo field, and how is this making my records jump about?
I'm trying to have a form sorted in a particular order when it's opened.
When using the "order by" option in the properties sheet, it is sorted the way I want the first time I open the form.
However, if I change the order afterwards while using the form (for instance, by right clicking and selecting another sort order), well the next time the form is opened, it is sorted with this new sort order, and not the default one.
So I tried to add the following code :
Code: Private Sub Form_Open() Me.OrderBy "employee_name ASC" Me.OrderByOn = True End Sub
I have a subform within a form that displays filtered data based on dynamic selection criteria which is assigned to the RecordSource/OrderBy of the subform. On this form, I have a "Print Results" button -- OnClick, I would like the RecordSource/OrderBy of the subform to be copied to the Report, then run the report. What I have that doesn't work is:
I have a tabular form that is based on a select statement (Query) in the source property. It filters & sorts from this select statement. permanently
I have just added a Me.Filter = "[Form1].[InDate] = #" & MyValue & "# " Me.OrderBy = "Indate DESC"
This all works fine, filters & sorts on the existing results.However this new filter & sort seems to remain no matter what I do.I have used every variation one me.filter ="" with Me.FilterOn = True, False & every combination.
Me.Filter="" & Me.FilterOn = False does initially seem to clear the lsit to show all records but as soon as type anything that filters the Form on the original, existing underlying select statement the extra Filter Property & Sort properties are occupied with the last filter/sort.
I have manually deleted any remaining Filter Or Sort properties direct from design view, saved, compacted & saved again.Once I use the new me.filter it will always returned as soon an any filter on the form is applied.I definately am not setting it again anywhere. Is there something better than me.filter ="", seen clearallfilters mentioned but not sure if this would apply just to the current form but reluctant to use a blanket clear as I do have quite a lot of other things going on.
Not sure when but many months (If not years) ago my form source stopped being a query and started using the query (sql) direct from the source property.I have left it this way as not sure if any consequence of moving back but don't remember how or how it happened. What are the pros cons of using a separate query.
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
hi guys.. i want to include a search form in my database.. here is my current SQL statement:
SELECT tblCompany.CompanyIDPK, tblCompany.CompanyName, tblCompany.CompanyAddress, tblCompany.ContactPerson, tblCompany.ContactPosition, tblCompany.OfficeNo, tblCompany.MobileNo, tblCompany.FaxNo, tblCompany.EmailAdd FROM tblCompany WHERE (((tblCompany.CompanyName)=[Forms]![frmSearchClient]![txtSearchFor]));
but this statement only returns the exact name of the company... if the name of the company in the database is ABC company and you searched for "ABC", it will return zero results... so how can i improve on this? that even if they enter only "ABC", it will return a result.
I'm making a student report card. Teachers enter student data via a bound form. I have a text field that teachers enter their class which brings up student names. They fill oput the form accordingly.
I have 6 classes of grade 7. 7A, 7B, 7C and so on.
If a teacher enters something weird like (7 (space) A) the query bound to the form will return nill results because it's looking for something that doesn't exist. I need an error message to appear which says no records will be returned because you haven't entered the correct parameter value. (Because they have entered 7spaceA rather than just 7A.
I could just use a combo and this would solve all my problems. But it's not always practical. I was thinking I could use a wild card where if the first character was a number then at least some values would be returned. There is method to my madness... I actually want to apply the same code elsewhere when running reports.
Is there a way I can enforce some kind of input mask in an event proceedure that can do this??
I have data of type "number" shown in the drop-down combo-box in a form. It has some codes in the event of "After Update".
My problem is that i can't type in something like 13* in the combo-box in order to get anything starts from 13. It says "The value you entered isn't valid".
The reason is that i want user to be able to use the wildcard. I know that i can do this with text. I'm not allowed to change the structure of the table in the database.
This combo-box shows IDs from one of the exisiting tables. That IDs is of type "autonumber" in the table.
I've got a query that is defeating me, but that might be due to a week's worth of insomnia related sleep problems. My issue exists in the following query, of the four IIF statments in the HAVING portion of the query and the need to select all if the statement is false for each one of the four queries, the way it is now partly works by returning all results where none of the values are null, I need to get null results as well. I've tried not including the false action for them, a wildcard to select all and just can't get around this problem. Any help appreciated.
SELECT DISTINCT vw_mdb_SalesSummary.Channel, vw_mdb_SalesSummary.Store_Number, [AOI Category groups].ProductType AS Category, dbo_Contact.Source_of_Inquiry, dbo_Company.Rn_Descriptor AS Store_Name, vw_mdb_SalesSummary.Job_Number, Sum(vw_mdb_SalesSummary.Extended_Price) AS Sales1, vw_mdb_SalesSummary.Designer_Code, vw_mdb_SalesSummary.Manager_Code, 0 AS Sales2
FROM ((dbo_Company RIGHT JOIN vw_mdb_SalesSummary ON dbo_Company.Store_Number = vw_mdb_SalesSummary.Store_Number) LEFT JOIN dbo_Contact ON vw_mdb_SalesSummary.Job_Number = dbo_Contact.Job_Number) LEFT JOIN [AOI Category groups] ON vw_mdb_SalesSummary.Category = [AOI Category groups].SalesCategory
WHERE (((vw_mdb_SalesSummary.Order_Date) Between [Forms]![frmLandS]![currentStart] And [Forms]![frmLandS]![currentEnd]))
GROUP BY vw_mdb_SalesSummary.Channel, vw_mdb_SalesSummary.Store_Number, [AOI Category groups].ProductType, dbo_Contact.Source_of_Inquiry, dbo_Company.Rn_Descriptor, vw_mdb_SalesSummary.Job_Number, vw_mdb_SalesSummary.Designer_Code, vw_mdb_SalesSummary.Manager_Code, 0
HAVING (((vw_mdb_SalesSummary.Channel)=IIf([Forms]![frmLandS]![Channel]<>"",[Forms]![frmLandS]![Channel],[Channel])) AND ((vw_mdb_SalesSummary.Store_Number)=IIf([Forms]![frmLandS]![Store]<>"",[Forms]![frmLandS]![Store],[vw_mdb_SalesSummary]![Store_Number])) AND (([AOI Category groups].ProductType)=IIf([Forms]![frmLandS]![AOI]<>"",[Forms]![frmLandS]![AOI],[ProductType])) AND ((dbo_Contact.Source_of_Inquiry)=IIf([Forms]![frmLandS]![source]<>"",[Forms]![frmLandS]![source],[Source_of_Inquiry])));
Im trying to create a query that uses a combo box as the filter criteria. However the combo box needs to use wildcards, which i would have thought would have been *[forms]![control]![combo1]*. However this doesnt seem to work, anyone know what im missing?
I have a table called Coded_Data with one particular field called Codes. This field list a number and a respective code to identify what type of code it is. For instance 123456789-AD...123456789-ADS. I am wanting to create to two columns. One listing all work orders coded with AD and the other withADS. When I use the Like condition with % it returns both AD and ADS in same column. I understand why because the "%AD" returns anything that starts with AD so this is why I get both codes. I only want to get the the AD codes in one column and ADS in the other. I have duplicated the table twice since I am trying to retrieve data from the same field and table but display in 2 separate columns. The duplicated table has a different alias. The problem is in the where clause.
where (((coded_data.codes) LIKE "%AD")) or ((coded_data_1.codes) LIKE "%ADS");
I'd be grateful if someone could offer some help with this to a frustrated Access novice : )
I have a query that filters records according to the value of an unbound text box in my form (basically search on last name)
I want to introduce wildcards into the filtering process but cannot get it to work.
Here's what I've done:
In the criteria field I had [Forms]![MAIN]![Text440] refering to the unbound text box on the form already mentioned.
This worked fine, but the following: Like "*[Forms]![MAIN]![Text440]*" does not.
Nor does various combinations of brackets such as: Like "*([Forms]![MAIN]![Text440])*"
In fact it now doesn't return anything, even if given a positive match. I have trawled help and the forums but to no avail. I have also tried the % character instead of *
I have created a simple Unbound search form based on a 'Bookings' table. There are 4 comboboxes that the user can choose to search on, 'Client_ID', 'BookingType', 'FundingArea' and 'ChargeTo'. I have created a query that uses the following criteria;
Like "*" & [Forms].[frmLBT_db_Tool].[cmbName] & "*" Like "*" & [Forms].[frmLBT_db_Tool].[cmbBookingType] & "*" Like "*" & [Forms].[frmLBT_db_Tool].[cmbFundingArea] & "*" Like "*" & [Forms].[frmLBT_db_Tool].[cmbChargeTo] & "*"
Using this criteria any of the comboboxes can be left blank and the results will display the chosen combobox used, or if 2 comboboxes were used the results would be further filtered.
The problem I have is that if a name was chosen (cmbName - Client_ID) and the Client_ID was 2, then all Client_ID records which have a 2 in them are returned, 2, 12, 20-29,32,42,52 etc...
Is there a way to overcome this, or am I going about it all wrong?
Is it possible to update vlues in a table using wildcards. I want to use a query to search for certain records that meet a certain criteria and modify these values like changing particular dates in the date field to new values.
I have a table with a string field for a street. It might have data such as:
Bleeker Street or Bleeker St.
I want to create a query that will enable the user to search for a string by entering a parameter. Is there a way to construct a query using wildcards for a string so that if the user types in "Bleeker" both the above values will be returned?
Been trying to use wildcards in fields while Filter By Form instanced in Access 2007.
LIKE, BETWEEN, IN or */% not available?
The form is based on a query. I am guessing this is why the drop downs only show IS NULL or IS NOT NULL as choices instead of the entire unique list existing in the underlying table/query.
I should find the position of a number in a sentence and later extracted. The number is attached always to an "E". ie: E1, E2, E3,E4. The range of the number is 1-4. I have this until now:
I have a Excel spreadsheet with an embedded query that pulls from an Access table. The users use a spreadsheet with an embedded query to search on a field called "Circuit ID", to bring up results showing the history of a given circuit id. Currently they have to enter an exact match, for example if the circuit id value is DHECHUIOY, they need to enter this exact value DHECHUIOY. They want instead to be able to enter DHEC and a wildcard character to bring back every value that begins with DHEC. There doesn't seem to be a way to do this in a spreadsheet with an embedded query.
I finally decided that it would be easier to create a form in Access
How I can create a form which allows users to search on a value using wildcard characters ? (the user enters the wildcard character).