Modules & VBA :: Using IIF Statement To Search A Field For Contents
Dec 18, 2013
I need to use an iif statement to search a field (column) for a certain word. The field is in tblEquipmentName and the input is in tblWorkReport
Ex.
iif(input from tblWorkReport is in field from tblEquipmentName,...,...)
View Replies
ADVERTISEMENT
Sep 11, 2013
I am trying create some code that checks if the contents of the status field in a table is "Authorised" where the ID = something specific for multiple records. If all records witht the specific ID are "Authorised" Then generate a new record in another table. Where to start, perhaps a Dlookup?
View 1 Replies
View Related
Jul 11, 2013
I've got some code that loops through a record and copies the non-null fields to another record. This is the partial code:
For Each fld In tdf.Fields
If Not IsNull(Forms!contact_lookup![Contact_sub subform1].Form(fld.NAME)) Then
strSql = "UPDATE tbl1 SET tbl1.[" & fld.NAME & "] = '" & Forms!contact_lookup![Contact_sub subform1].Form(fld.NAME) & "' " & _
"WHERE tbl1.[FC_APN] = '" & Me.txtApn & "';"
DoCmd.RunSQL strSql
End If
Next fld
This works fine until it encounters a field whose contents has a reserved character, like a single quote (" ' ") in it, for example, "What's the what." At that point the SQL thinks there's a " ' " missing in the statement, and I get an error 3075 (syntax error: missing operator).
View 2 Replies
View Related
Jul 14, 2006
Hi,
I'm making a form where the contents of a field is determined on the contents of another field in another form. I thought an IIF function would work, but when I tried it the contents says #NAME.
I put it in the control source.
IIF([Forms]![Frm_NewBusiness]![Page4]![Child51]="NTU",NewBusiness_Date_Issued="NTU",NewBusiness_Date_Issued)
Any ideas?
Cheers,
Ben
View 1 Replies
View Related
Dec 8, 2013
I'm trying to make a search form that makes use of queries that search a table based on what fields I have. How would I go about having the query display all the fields for the record(s) that match the search criteria? This is for Access 2010.
As far as the query is set up, I have several fields with a search criteria, and the others are for displaying the relevant information about the results (since they're not search criteria, I used "Like '*'"). When I ran the query, it doesn't come up with anything - even if the record actually exists in the table with specified criteria.
View 9 Replies
View Related
Jul 8, 2015
how to read a specific line in a CSV file (using VBA), to see if the phrase "There are no records available." is present.
If it is present, then I'm going to do a debug.print stating that there are no records to load - and then the script will move on to the next file. If the phrase isn't present, then I'm going to upload the file to Access, parse the information, and then upload it to a CRM. (I already have the latter portion of the code up and running....I just need to account for the first part, where I can determine if the file has data or not).
The structure of the file never changes. The first row is composed of eight column headers (Post Date, Card Number, Card Type, Auth Date, Batch Date, Reference Number, Reason, Amount) and (if) the phrase "There are no records available." is present, it will show up on the second row, in the first column (under Post Date).
View 3 Replies
View Related
Nov 27, 2013
I am trying to write a statement and it returns: #Type!. I know what this means but it should not give this error.I have button that copies a certain number of fields to the clipboard. The one below is one of them. Here is the coding I am using that works:
Code:
=Trim(IIf([CallingContactRel] Is Not Null,[CallingContactRel] & ": " & [CallingContact],[CallingContact]))
I would like to add the following condition to this code. I have a yes/no field called BookingNoteContactExcl. If this is ticked, it should exclude [CallingContact] from being copied, in other words, return "" in the code above.
View 8 Replies
View Related
Aug 19, 2014
My update statement is shown below. What this is to do is change the PGTIN record in PP TBL to the GTIN that is in the UPC TBL where the UPC Code on the form is the same as the UPC Code in the UPC TBL. I am getting the error message "can't find field..." I have double and triple checked the field names but cannot find my error. Both PGTIN and UPC Code are text fields.
strSQL = "UPDATE [PP TBL] SET [PGTIN] = '" & [UPC TBL].[GTIN] & "' WHERE ([UPC TBL].[UPC Code] = '" & Me.UPC & "');"
View 6 Replies
View Related
Jun 6, 2014
I have a table called login and inside that table is three columns: username, password and admin.
I have the username saved in a global variable called GsUser. How can i find the record in that table with the same Username as the string stored in GsUser and use that record for an if statement which sees if the value of the admin column is "Yes". Im trying to do it using VBA. Im not using a form where everything is bounded.
View 2 Replies
View Related
Aug 30, 2013
I have a form with two list boxes on it: listAllBANANA and listActiveBANANA
The listboxes are populated from tblBANANA. Active is defined by the tblBANANA field "ResponseDate" being Null.
Also on the form is a CloseBANANA command button. When pressed with no selection, it opens frmCloseBANANA to the first record. If a BANANA is selected in listActiveBANANA, the form opens to the selected record.
Now comes the tricky part: if a BANANA is selected in listAllBANANA, I first need to verify they have an Active BANANA selected, before opening the form. I've poked and tested and searched and cut and pasted my little fingers off with no joy. What I've deduced is that I'm either messing up the syntax of the DLookup or I'm incorrectly referencing the selected record. There's also the third option that I'm going about this in entirely the wrong way.
All other code below works. If I delete or comment out the line in red, I have no issues other than I may open up a blank form because I'm trying to close a BANANA that is already closed.
Code:
'If a BANANA is selected in Active BANANA or All BANANA, open Close BANANA to that record. If not, open form to most recent record
Private Sub cmdCloseBANANA_Click()
If Not IsNull(Forms!frmGUI!listActiveBANANA) Then
[Code] .....
View 8 Replies
View Related
May 18, 2015
I am using the following to add a column to an existing table. How do I make this column indexed with no duplicates?
db.Execute "ALTER TABLE [BrandTBL] ADD COLUMN UPCGroupName TEXT;"
View 1 Replies
View Related
Sep 22, 2014
I have a lengthy CASE statement in my database that displays specific text in a field based on the value of another. Simple stuff but for some reason it randomly will not work on certain values, and never the same one twice. Is there a commonly known cause for this? I have verified that the spelling and spacing etc. are correct in my code so that shouldn't be causing the problem.
View 2 Replies
View Related
Sep 26, 2013
I need to find out where the field called "R_SHIFT" is being referenced in all our MS Access queries. I just need the query name so I can go into the query and change the name from "R_SHIFT" to "SHIFT"
I was thinking there was a function for Modules to Find Field? I have never done any Modules before..
View 3 Replies
View Related
Jun 19, 2014
I'm fairly new to Access / VBA and have been trying relentlessly to get a text box / search button on my Access form to pull up a specific record. Although the null command produces the correct error msgBox, it does not show any record if I enter a correct primary key term.
Search button = SearchButton1
Search criteria = SearchText1
Primary key field = UniqueAEVRef
Code:
Private Sub SearchButton1_Click()
If IsNull(SearchField1) = False Then
Me.Recordset.FindFirst "[UniqueAEVRef]='" & SearchField1 & "'"
Me!SearchField1 = Null
If Me.Recordset.NoMatch Then
MsgBox "No record found", vbOKOnly + vbInformation,
Me!SearchField1 = Null
End If
End If
End Sub
View 5 Replies
View Related
Oct 2, 2013
I have a report that has multiple fields - 3 of which matter for this discussion -
1.) employee
2.) employer
3.) rateofpay
The employer field contains 1 of 2 options. For the sake of this conversation, lets call it ABC123 and XYZ123
I need to be able to calculate the average rate of pay for ABC123 company, and exclude the rate of pay for XYZ123 company in my report.
I am calculating this in a section footer.
View 2 Replies
View Related
Apr 26, 2013
I am trying to perform a search function query in access but am having trouble. I have two tables. One table has a column in which I need to search the contents of this field by referencing data in another field/table. I am able to write the query searching the data manually (not referencing the other table) but can't seem to get the query right when referencing the other table!
this query works =
SELECT *
FROM Sample_Data
WHERE (((Sample_Data.[Affected_Frequencies]) Like "*451.425*" Or (Sample_Data.[Affected_Frequencies]) Like "*451.400*"));
but, i put together a frequency table (Table name = Frequencies) and the column within that I am searching for is called Frequency. im trying to reference Frequencies.Frequency using a LIKE statement.
View 1 Replies
View Related
Jul 4, 2013
I have a search form that looks up a value in a field and lets the user know if it is there or not, they have now asked to put in multiple values to search... eg. searching containers number, I will put user input box where they can put these numbers
NYKU023561
TRLU102356
TCNU123023
This will search my container number field and show a pop up message box saying..
Please note below
NYKU023561 - has been found you cannot use this container
TRLU102356 - has not been found please check internal system
TCNU123023 - has beeen found you cannot use this container
Below is the basic search I had before which was all I needed.. how can I adapt this?
Code:
Private Sub Command256_Click()
If (CntSearch & vbNullString) = vbNullString Then Exit Sub
Dim rs As DAO.Recordset
Dim CNT As String
[Code]....
View 4 Replies
View Related
Jan 16, 2014
I import a CSV field which has not preserved the CR/LF when it was exported from BCM Remedy. There is no setting for that. The memo field prints on my report like this:
A custom solution would be developed, that once implemented, could become the standard product in similar situation. Normally would assign to Network Engineering, but will work with Ray and the IPT Team to cost out the solution and get approval to proceed. 2012/05/24 10:44:28 AM PCOLLINS Sent to Ray Massie for review to determine if a solution needs to be proposed, or if they can wait for the National IPT solution to be ready in 2013.
I want to add VBA code that inserts a CR/LF in the memo field before all but the first occurance of a string that looks like a date, the first occurance doesn't need it. I will do it right after I import the CSV file into the table, so it happens only once, and it always prints and displays the CR/LF.
The memo field is called "NBS Update" and the table is called "CCRR Remedy Data"Here is what I have, but don't actually know what to put in to find the date and add a CR/LF:
Code:
Dim db As DAO.Database
Code:
Dim db As DAO.Recordset
Dim srtSQL As String
[code]...
View 14 Replies
View Related
May 3, 2014
Me.TxtNotAllowed.Visible = True
dtTimer1 = Now
dtTimer2 = Now + TimeValue("00:00:10")
Me.TxtNotAllowed.Value = "You do not have permission to use this database !"
Do Until dtTimer1 >= dtTimer2
dtTimer1 = Now()
Loop
Me.TxtNotAllowed.Value = ""
DoCmd.Quit
The above code will run definitely for the 10 seconds however the textbox and contents do not display HOWEVER if stepped through with breakpoints line by line and the form checked each time the textbox DOES display and its contents.
View 3 Replies
View Related
Feb 14, 2014
I would like to ask if it is possible to use the contents of a table as a comparator? For example, I have this column in my table that has the schedules of the professor, if the professor for example failed to login within fifteen minutes after his/her supposed start of class a message will be displayed on the screen notifying that the professor has not yet logged in.
View 1 Replies
View Related
Sep 1, 2006
Is there a way to make the value of one field change dynamically based on the values in other fields on the form?
Here's the general idea. I have two tables.
RecordTable
--------------
SiteID, etc.
SiteTable
-------------
SiteID, SiteBlurb
I want have a form, where you can change the SiteID value in RecordTable, and have the SiteBlurb change (i.e. the form pulls the information from SiteTable) dynamically once you have entered the new value.
View 1 Replies
View Related
Jun 18, 2015
is there an alternative to making a field blank, other than my old trusty <Me.Field1 =""> ... ?
(my use of the < and > are purely for demonstration purposes, and do NOT get used in code)
I'd like some fields to be native, virgin, blank, et cetera... I do find sometimes I have to overly complicate a VBA statement by putting.. <If IsNull(Me.Field1) or Me.Field1 = "" then> because I have made that field value = "" to blank it out.
View 3 Replies
View Related
Jan 11, 2007
My company requires a query to aid distribution, however I am experiencing some problems implementing the system.
We have purchased a large database of addresses and need to be able to query a town/street to find out how many houses are in that street.
I have the query and form set up to display the street/town and list of house numbers when searched for, however the houses are grouped by postcode rather than street, with multiple house numbers in the same field (see example).
Street
Main Avenue
POSTCODE
HG23 0DF
Houses
89;91;93
POSTCODE
HG23 1DF
Houses 95;97;98
----
Basically, I need a total of how many individual houses there are in a street, regardless of postcode. In this case, it should treat the ";"s as dividers and return the result of '6'. Or in some cases ignore the semicolons as some fields look like ";;;;;;;;13". It should then add both the total for one postcode to the other postcode to display a complete total of houses in one road.
Can anyone make any suggestions?
Thanks in advance,
Matt
View 1 Replies
View Related
Feb 21, 2008
HI
Is there a way that i can split the fields based on the delimiter that i will set in a query?...
for example : 088H-FJAKSDF-SAFN-F
in that case additional four columns will be added becuase it will be separated by a dash (-)
thanks so much for your help.
View 14 Replies
View Related
Oct 14, 2004
Here is one that I could use some help with.
I have an Updates field in all of my tables. It, of course, holds my audit trail. Im tryiing to figure out a way that I could run a single command and clear the contents of all the Updates fields on all the tables in my db. Ideally, I'd like to auto generate a report for all the update fields on all the tables, then do a purge.
Any ideas?
View 4 Replies
View Related
Jul 3, 2012
I'm an excel user and in using excel I can take two fields and combine their data in one field. I've got about 6 database files with anywhere form 1000 to 3000 records that have already been prepared and imported into access database files .mdb and I realize that the firstname lastname fields need to also be combined into a contact field with both names. In Excel it's easy in access I'm a little lost. I was looking to an update query however I can't find instructions on what I'm trying to do.
View 2 Replies
View Related