Queries :: Pull Text From String?
Apr 2, 2015
I have a text field in a Table and on a Query called "Notes" In that field that has data like below:
[04/02/2015:BD] Project is to be assessed by Solutions Planning
[03/27/2015:BD] Project prioritized
[03/14/15:BR] Entered to system
Im trying to find a way to pull just the most recent line of text, in this case
[04/02/2015:BD] Project is to be assessed by Solutions Planning
into the field next to "Notes" or wherever - an empty field in the query. I searched around, found some stuff and I was thinking of having the code look at the first "[" and count the length to the next "[" and pull out whats in between. Looks like the bracket causes issues in the module.
View Replies
ADVERTISEMENT
Nov 13, 2013
I have a text file linked to this database, and I'm trying to create a Query that will pull all of the data out of this text file, and add a rank if two of the values match in multipe records.So in other words, when multiple records have the same [JOBNBR] , I want to evaluate the [TIMESTAMP] value to see if it is the smallest one, and so on.I don't want to create multiple queries to do this, is there any way to do this? Here's what I have:
Code:
DDR: (Select count(*) from tblMyDataImport Where [tblMyDataImport].[TIMESTAMP] < [TIMESTAMP] AND [tblMyDataImport].[JOBNBR]=[JOBNBR] )
View 5 Replies
View Related
Feb 28, 2005
Sorry if this has been asked before but I have searched and couldn't find an answer
I have a string that is set on startup (username) and have another form(hidden) that loads on startup this form contains information on what forms and options the user can access. Just having a little trouble using the string to pull the correct record, the information in the string would be from the primary key field on the table.
Thanks
Ryan
View 2 Replies
View Related
Jan 3, 2014
I have a series of IDs in an 'articles' table stored as text, e.g.
hb-123456789-e-068
hb-123456789-e-0069
hb-123456789-e-70
hb-123456789-e-00027
and I'm trying to pull the max value of the number after the -e- for a given set of them. In this example, I'd want to return the number 70. I'm then going to use that to create the next ID and populate another field.
The IDs are not used as the primary key. And while the previous IDs used leading zeros inconsistently, new IDs will not have leading zeros.
Here's what I have so far, but it doesn't seem to pull the number after the -e- at all. I think this section here is the problem, even though the same logic works in a query:
Code:
selectedERef = Val(Right(rs![masterArticleID], Len(rs![masterArticleID]) - InStrRev(rs![masterArticleID], " - ")))
Code:
Public Function MaxArticleERef(hbID As Long) As Variant
On Error GoTo err_handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim maxERef As Variant
[code]....
View 3 Replies
View Related
Sep 10, 2013
I'm trying to find a function in access that could do the following:
ZAB103-3012
ZAF405-HD-0001
Turn those cells into:
AB103
AF405-HD
Pulling everything to the right of the Z in the last step is the easy part but I can't figure out what function would be able to find the last "-" in the cell and pull everything to the left of it.
View 6 Replies
View Related
Sep 12, 2006
I have a 3rd party database where I have no control over how the data is entered. I've been given the task of creating a Crystal report that would need to gather data from two databases. The link between the two databases in my report would be on a quote number. In one database, the quote number is in it's own field. In the 3rd party database, the quote number is stored in a memo field along with other data.
Here's an example:
4000 C7875
9003267 T7761
90000167/4010/T6895
4010 T7152A
TPCA #1756/2914
The data I'm after is
C7875
T7761
T6895
T7152A
*No data from the 5th row since the data after the "T" isn't numerical
So far I'm thinking of using an IIF statement to check for the existance of a C or T, then if true, use a nested IIF statement within the first to check for numeric, if true, use the Mid function to pull out the quote number.
My first concern is this could become a complicated IIF statement and was wondering if there was another direction I should be looking in acheiving this.
My second concern is if I go with this method, some of the quote numbers have a space after them, some of them have no space after them, some may even have a "/" after them. How would I go about accomplishing this?
View 5 Replies
View Related
Mar 24, 2014
In my query, I have the week number and year arranged like this - "Y14-W11"
I want to return a value in a text box on a report if the string contains, for example, W11. In this textbox I've put the expression
Code:
=IIf([Y##-W##]="*" & "W11" & "*","2100000","BLAH")
But this just returns the falsepart no matter if the string contains W11 or not.
View 3 Replies
View Related
Apr 17, 2014
I'm working with a table of financial transactions. I need to know the date a record relating to cash received actually arrived in our bank, but the software doesn't allow the user to enter this, so I've asked them to enter it into a text reference field, e.g. 'Other Text XX 16/04/14', and then I've got a formula - CDate(Right(Trim([RefField]),8)) - which takes the date from this reference.
This works fine, but it's really important I don't miss any of these records due to the date not being entered, so what I'm trying to make is a formula which will give me the date from the ref field as in the formula above if there is one, but if that formula gives an error (so the date has been missed out or incorrectly entered) then I want to take the date from another field, called [DateAdded] as a failsafe.
I can't work out a formula that won't give me an error, i've tried loads. First I tried :
iif(iserror(CDate(Right(Trim([RefField]),8))),[DateAdded],CDate(Right(Trim([RefField]),8)))
But that gives an error, and I think from looking at forums that Access evaluates both parts of an Iif function so it'll do that.
It seems like other people are saying that you need to use Nz, IsDate or IsNumeric or something along those lines instead of IsError to evaluate the field, but I can't get that to work as it's not a field, it's a portion of a text field.
This is my latest attempt:
Join Date: IIf(IsDate(Right(Trim([RefField]),8)),[DateAdded],[Calc Date]),
where [Calc Date] is an expression field with CDate(Right(Trim([RefField]),8)) in it, but there's the #Error again.
How can I use iif to pick either a date from a text string, or where that results in an error then another date field?
View 9 Replies
View Related
Feb 2, 2012
I need to find a way to search through all of the queries in my Access 2007 database to change the names of more than a few variables. There are close to 900 queries I need to search through many of which may use the variables as criteria, so if I miss even 1 instance I might screw myself completely.
I found this post and it tells me exactly what I need to do. Only problem is the post was written in 2002, and I've followed the below instructions only to have it not work.
As a contractor working predominantly on databases I haven't developed, it can be a daunting task trying to find references to tables, fields or functions within a list of several hundred queries.
The following code is attached to a command button on a simple form listing all queries in the database. The record source for the form is
SELECT DateCreate, Name FROM MSysobjects WHERE Type=5 ORDER BY DateCreate DESC
There is a text box where the user enters the text to search for. The code builds a table containing the SQL string of every query, then searches for the required text, and displays those that match.
Your form also needs a procedure the set the record source back to the default.
There are off-the-shelf applications such as Speed Ferret which perform this sort of function, however some employers are too cheap to purchase them!
Code:
sub cmdFilter_Click()
Dim db As Database
Dim rs As Recordset
Dim rsFilter As Recordset
Dim tdf As TableDef
Dim strSQL As String
Dim strQdf As String
On Error GoTo ErrorHandler
[Code] ....
View 11 Replies
View Related
May 15, 2013
I have one field where string contains several words separated by semicolon and my goal is to be able to remove duplicates within the string and keep only unique values. Here is an example:
initial field:
xxx;yyy;ppp;yyy
targeted result:
xxx;yyy;ppp
How this could be achieved ?
View 5 Replies
View Related
Apr 25, 2014
I have a list of consumables;
Syringe 50ml
Syringe 20ml
Syringe 5ml
Syringe Cap
White Needle
I want to remove only the number and the ml part from the list, so I would end up with;
Syringe
Syringe
Syringe
Syringe Cap
White Needle
If I use
PHP Code:
Replace([DrugNameVial],"50ml","")
I get the desired result for the 50ml syringe size.
I have tried every possible combination of "**ml", "##ml", "Like [0-9]ml all with no success.
How this can be resolved without having to individual enter each syringe size "5ml", "20ml" etc
I can't even just take the text from the right till the first space as this would lead to problems with other consumables in the list.
View 5 Replies
View Related
Jul 6, 2006
On my first form I have a pull down box and when I select an item and click the add button, the item appears in a locked text box above the pull down box. After I click the submit form button, it goes to another form. On the other form is a similar pull down box and locked text box. So far I got the item selected on the first form to appear in the second form's locked text box.
Again, the second form also has a pull down menu and when I select another item from the pull down box and click the add button on the second form it deletes the first item selected in the first form from the second form's locked text box. The items selected are put in a table. I was wondering if there was some kind of code I can input so the second form's locked text box keeps the first value from the first form and can add additional values when selected through the second form's pull down box. Sorry if this sounds confusing. I really appreciate your help. Thank You.
View 1 Replies
View Related
Aug 10, 2005
Looking for an automation solution
currently I have a database for client progress and prescriptions. when the file is opened it is set for data entry so that a clean note form is opened. I have a button that pulls up past notes for their review.
it has been requested that there be a way to pull the last narative field forward to the new record for editing as a number of the features of the narative remain the same.
Currently the only way is for them to open the last seen note hightlight the field and past into the new note. to high level for some of them.
Need to make this an automated feature where they would just click on a button and the process would all occur behind the scean and the note would apper in the new note narative box.
I know that I could tell the form to not be for data entry but then they write over the last note. this needs to be a new record.
Any suggestions greatly appreciated
J
View 1 Replies
View Related
May 21, 2015
I have a perplexing problem. I'm creating a simple db to enter borrower audit checklist data with the following tables:
Questions -- A list of 17 pre-defined audit questions, with fields QNum and Question
Audits -- One record for each audit (pk AuditKey is an Autonumber), and some borrower fields
AuditQuestions -- Linked to Audits, with pk of AuditKey and Qnum, and a Question and Answer (yes/no) field
The Audits form has the Audits table as its datasource, and an AuditQuestions subform. When I go to a new Audits record, there are initially no subform records attached. When I enter a borrower name, the field AfterUpdate event runs the following code:
Code:
DoCmd.OpenQuery "LoadAuditQuestions"
Me.AuditQuestions.Requery
The SQL for LoadAuditQuestions is
Code:
INSERT INTO AuditQuestions ( AuditKey, QNum, Question )
SELECT [Forms]![Audits]![AuditKey] AS Keyval, Questions.QNum, Questions.Question
FROM Questions
ORDER BY Questions.QNum;
I start out with both Audits and AuditQuestions tables empty. When I run the code by entering a borrower name, I get, "... can't append all the records in the append query ... didn't add 17 records due to key violations". It acts like it's getting a null value from Forms!Audits!Auditkey, but if I select the Debug option and check the value from the Immediate pane, it shows a valid number. Also, if I run the query manually with the form open, it loads the questions correctly.
The first Audits record is loaded with questions in the subform so you can see the desired results. To see the problem, go to a new record, enter a name, and hit tab. Another piece to the puzzle is, if you do this on an existing record, it works fine: Click No in response to the error message that appears, then click End on the Debug message. Go to a different audit record, then come back to the one you just created. Change the name, and it works correctly. It's as if it doesn't know what the AuditKey is the 1st time, but if you check it in debugger, it is loaded. In fact, I put in code in the AfterUpdate event to plug the LoanNumber field with the Forms!Audits!Auditkey value, and it worked, but the subsequent query still failed.
View 3 Replies
View Related
Dec 21, 2012
I have a form where I want a textbox [txtMaxOrdLimit] to be visible only if another text box on the same form [PaNumber] contains the letter D in the string. This is the code I have on the forms On Current property but I'm missing something because textbox [txtMaxOrdLimit] doesn't show on the form at all.
If Me.PaNumber = "*D" Then
Me.txtMaxOrdLimit.Visible = True
Else
Me.txtMaxOrdLimit.Visible = False
End If
View 3 Replies
View Related
Jul 17, 2015
We're looking at a way that we can easily display what stage our clients' email marketing campaigns are at - in one section of our CRM our Campaign Manager will enter information on whether the campaign has broadcast (ie: emailed out to the required circulation list(s)), if we're waiting for artwork from the client or if we're chasing for that information.
I have four text boxes (date format) hidden on a subform that I need to pull ONE max date from.
So, as an example:
Email1 (our first email to the client chasing for artwork) = 01/01/2015
Email2 (our second email to the client chasing artwork) = 08/01/2015
Email3 (our third chase email) = 15/01/2015
Broadcast (the date the email campaign was finally sent) = 29/01/2015
I would need some code to show in an unbound textbox "Broadcast: 29/01/2015"
But, on the other hand, if the dates looked like this:
Email1 = 01/01/2015
Email2 = 08/01/2015
Email3 = Null
Broadcast = Null
I would need some code to show the following in an unbound textbox "Last Chased: 08/01/2015"
So we can easily see the status of our marketing campaigns at any stage in the process.
I've tried using IF THEN ELSE statements in the subform's On Current event, but that populates the information from the record you've selected across all the other records on the sub as well.
So I'm wondering if it's worth setting the Control Source of the unbound textbox I want to display the campaign status in as a bunch of nested IIF statements instead?
View 14 Replies
View Related
Oct 23, 2014
I'm trying to have users enter multiple IDs from a table into a text box separated by newline chars, and then (once they press a button) have some sort of macro or code read each line and pull a report I've created based on the ID. Is that possible?
Example:
Table
ID
DataPoint1
DataPoint 2
DataPoint 3
1
d1
d4
d7
2
d2
d5
d8
3
d3
d6
d9
Text Box (User will enter values and hit OK)
2
3
Report
ID: 2
DataPoint 1: d2
DataPoint 2: d5
DataPoint 3: d8
-------Page Break------------
ID: 3
DataPoint 1: d3
DataPoint 2: d6
DataPoint 3: d9
View 2 Replies
View Related
Jun 4, 2012
It is my understanding that a custom macro was built to pull text data from a file and import it into Access in the appropriate fields. This macro no longer works and will return the following error message:
"License information for this component not found. You do not have an appropriate license to use this functionality in design mode."
It only gives an option to click OK. When you do it shows a box called "Action Failed" that lists the macro name, condition, action name, and arguments with three button to click on the right of the box: "Step" "Halt" and "Continue". It appears that only the "Halt" button is available to be clicked.
Does this sound like an issue with the Access license or whatever license the macro might have? We're trying to decide if it's possible to restore the functionality of the macro.
View 14 Replies
View Related
Jul 31, 2014
I have two tables, one table Data has member(SUBSCRIBER_ID) data including service rep(UserName). Another table ServCoord has data including service rep and their manager. What I am trying to do is pull 5 random accounts per service rep. I can pull 5 random accounts, but not per service rep. I have currently 77 service reps. Is there any way I can pull 5 random accounts per service rep? Here is my starting point so far.
SELECT TOP 385 [Data].SUBSCRIBER_ID, Rnd(1) AS Expr1, [Data].UserName, Rnd(Len([UserName])) AS Expr2
FROM ServCoord INNER JOIN [Data] ON ServCoord.ServCoord = [Data].UserName
GROUP BY [Data].SUBSCRIBER_ID, Rnd(1), [Data].UserName, Rnd(Len([UserName])), [Data].SUBSCRIBER_ID, [Data].UserName
HAVING ((([Data].UserName)<>"NULL"))
ORDER BY [Data].UserName, [Data].SUBSCRIBER_ID;
View 2 Replies
View Related
Aug 6, 2013
I have 1 query that connects 4 of my tables through a tracking number. I am trying to make it so the value (DStatus) from DTable will populate where a (DStatus) is provided, but where there is no (DStatus) the column is filled in with a (SStatus) from STable. There is always a SStatus for each tracking number, but not always a DStatus, where there is a DStatus, it is more accurate.
Can I do this all in 1 query, whether I have to make a new column within my query for this to work, whether I need to have my query output into a table first.
Is there something I could type into the Criteria field of my query.
I have tried using Nz([DStatus],[SStatus]), an Iif Statement, the IsNull function, etc with no avail.
View 3 Replies
View Related
Mar 14, 2012
I have 2 reports that use a separate query to pull their data. One Query is called "Outdoor Lighting by Model Number Full Query".It is very simple, pulling just 4 pieces of data, SQL code is as follows:
SELECT DISTINCT [Call Log].[Model #], Sum([Call Log].Quantity) AS [Sum Of Quantity]
FROM [Call Log]
WHERE ((([Call Log].Date) Between [Forms]![Date Range Entry]![Start Date] And [Forms]![Date Range Entry]![End Date]) AND (([Call Log].[Product Type])=4))
GROUP BY [Call Log].[Model #]
ORDER BY Sum([Call Log].Quantity) DESC;
I run a report named "Outdoor Lighting by Model Full Report" which takes the above query. The detail portion of the report only has 3 sections:
Model #, Quantity, Percentage. Quantity I have showing "Sum Of Quantity" and Percentage is showing "=[Sum of Quantity]/Sum([Sum of Quantity])" Therefore, for a particular model # it gives me the number and then calculates what percentage that number is of the total. Works fine.
My second report is laid out exactly the same, except it pulls data from a different query that only returns the top five results. The code for that query is as follows:
SELECT TOP 5 [Call Log].[Model #], Sum([Call Log].Quantity) AS [Sum Of Quantity]
FROM [Call Log]
WHERE ((([Call Log].Date) Between Forms![Date Range Entry]![Start Date] And Forms![Date Range Entry]![End Date]) And (([Call Log].[Product Type])=4))
GROUP BY [Call Log].[Model #]
ORDER BY Sum([Call Log].Quantity) DESC;
The second report, appropriately named "Outdoor Lighting by Model Number Top 5 Report" only shows the top 5 and then gives a quantity and calculates a percentage. My problem is that the percentage is calculated based off of the total of just the top 5 query. I need it to calculate based off of the total of the full query.
I currently have percentage doing this "=[Sum of Quantity(Top 5 Query)]/Sum([Sum of Quantity(Top 5 Query)])".What I want it to do is this "=[Sum of Quantity(Top 5 Query]/Sum([Sum of Quantity(Full Report Query)])
View 2 Replies
View Related
Mar 18, 2014
I have a table with the following values.
EMPLLOYEE_ID
JOB
PAY_DATE
LOCATION
Most employees have 10 to 15 rows. I only want to pull ALL rows for employees ONLY if there is a distinct count from DATE_PAID greater than 1. There are cases where an employee might have two pay checks generarted for the same PAY_DATE.
View 3 Replies
View Related
Jul 22, 2015
I have a query that is pulling a date from a Form. In my Query Criteria, I can put:
Code : >=[Forms]![frmAdhoc].[Date]
or
Code : <=[Forms]![frmAdhoc].[Date]
or
Code : =[Forms]![frmAdhoc].[Date]
And it works fine, but I don't want to hardcode the ">=", "<=" or "="
I would like the user to be able to choose ">=", "<=" or "=", from another field on the Form, so I am trying to code it on the query like this:
Code:
IIf([Forms]![frmAdhoc].[Variable]=">=",>=[Forms]![frmAdhoc].[Date],IIf([Forms]![frmAdhoc].[Variable]="<=",<=[Forms]![frmAdhoc].[Date],IIf([Forms]![frmAdhoc].[Variable]="=",[Forms]![frmAdhoc].[Date])))
But it isn't working for the ">=" or the "<=". It just gives me a blank result.
View 2 Replies
View Related
May 6, 2013
I have a query that pulls data from the following fields in 2 different tables:
Area1FloorPrep (tblFloorPrep) ex. remove ceramic tile
Area1Size (tblInstallationAreas) ex. 20 s/f, or just 20
Area2FloorPrep (tblFloorPrep)
Area2Size (tblInstallationAreas)....
All the way to Area20 (Floorprep and InstallationAreas) for both tables. I have created an installer invoicing form that pulls the data from the workorder that these fields are located in, but the problem I'm having is that I don't know what kind of query to create to concatenate the data in the 20 fields and concatenate the size of the areas next to the appropriate concatenated floor prep description. Is there a way to do this without coding?
View 3 Replies
View Related
Jun 24, 2013
I have two tables: Table #1) [Request Table] Customers request our company to stock a certain Part Number with a minimum value. Ajax - P/N "NP4i" - Min "30".
Table #2) [Sales History] All sales purchased and the "Qty-Total" purchased. For simplicity Fields are limited.I created a CrossTab Query that displays from [Request Table] P/N's requested/ min values (Row Headings) then showing P/N's purchased [Sales History] Value="Qty-Total" Sum and
Column=Format([Invoice Date],"mmm/yyyy") group by, showing last twelve months.
Ex: Customer name, Part Number, Minimum, May/2013, Apr/2013, Mar/2013 and so on.
AJAX, NP4i, 30 4 21 5 and so on.
The Crosstab query list only requested Part Numbers that have at least One sale wihin the last twelve months.If there are NO sales, the crosstab query will NOT show this Part Number.My boss wants to see the requested Part Numbers that were never purchased along with the ones purchased.He wants to address the NO sales, yet they requested we stock that particular Part Number for them.
Is there any criteria I can use to force the Part Number field on the [Request Table] side to populate even though there were NO sales within the last twelve months?
View 1 Replies
View Related
Jan 20, 2014
I have a form that is used to book a new event for a client who is already in the database.Within that form I have a subform that is based on a query which displays information from that client's previous event. I did this using a solution found in the following thread: URL...It is based on pulling the second to last record that is related to the current client. It works perfectly when booking a new event that has taken place on a previous date. However, if the previous event occured on that same date (but at a previous time), it doesn't register.
I would prefer a query that would pull the record previous to the current one, instead of pulling the second to last record out of all that client's events.it would also mean that if more events are booked, then a past event is opened in a form, the sub forms in that form will display the event just prior to the current record.
View 14 Replies
View Related