How To Refer To A Text Box With The LIKE Operator?
Sep 17, 2007
Hi everyone!
I'm working on creating a small database for the company I work at and just can't figure out the syntax to make this work.
If I create a query that looks for clients Like '*Smith*' , it returns records where the client is John Smith, Smith and Company, Edward Smith & Jones, LLC and that part works great! I did this by typing: Like '*Smith*' in the criteria field for Client in the design view of the query. (Also seems to work whether I use single or double quotes - not sure about the implications of that).
Now, I want to replace the word Smith with whatever a user enters into a text box, I can't get the syntax right! In the design view of the query, I've tried things such as: Like '*forms![Search by Client]![Text0]*' with no luck. Any ideas? Maybe I'm missing some brackets or parenthesis?
View Replies
ADVERTISEMENT
Apr 29, 2005
I have a Main form with two subforms Sub1 and Sub2.
I want to set the RecordSource of Sub2 from the OnGotfocus event on Control1 on Sub1.
My code is:
Dim intCtrl as integer
Dim strSQL as string
intCtrl = Me.Control1
strSQL = "Select * from MyTable where Id = " & intCtrl
Forms!Main!Form!Sub2.RecordSource = strSQL
Forms!Main!Form!Sub2.RecordSource.ReQuery
When Control1 gets the focus I get an error Runtime error 2465 Access can't find the field 'Form' referred in your expression.
Have tried many permutations but no luck.
Grateful for help.
View 1 Replies
View Related
Sep 25, 2005
I have a main report which has a subreport. On the main report I have txt fields that I want to change their background colors based off values in fields on the sub report.
Thanks
Jon
View 1 Replies
View Related
Feb 10, 2005
I have a form with 25 related sets of text-box controls:
Product1, ProdDescr1, ProdQty1
Product2, ProdDescr2, ProdQty2
... Product25, ProdDescr25, ProdQty25
I need to loop through all 25 to check that the ProdQty for each is correct, and if any of them are incorrect, I'd like to set the BackColor to Red and the ForeColor to White for that particular set of controls. Rather than coding all 25 checks, I'd like to use variables to loop through the 25 sets
I understand how to create an incrementing Integer variable, but what is the correct syntax for combining that Integer variable with the String variables in order to perform the Back/Fore color commands?
View 2 Replies
View Related
Feb 13, 2005
Hi All!
Well I got a problem and guessing this is possible to do like this but well after few hours and staying at the same point maybe some help can be greet
I have a database witch I have 2 important field and a command for this. A field called ID with a number and another called GenerationID who contain number between 1 to 12 depending of which generation is. I got this Generation ID from a subform. What I want is this:
Depending of the number in generationID field show a different button like ID3 with generationID = 3 or ID2 if generationID = 2 etc until 12 and then other command buttn is not visible.
I don t know how to put the code but the code probably look at this:
If generationID = 3 Then
ID1.Visible = False
ID2.Visible = False
ID3.Visible = True
Else If
generationID = 2 Then
ID1.Visible = False
ID2.Visible = True
Id3.Visible = False
End If
End If
or if you have a better way all is welcome.
View 4 Replies
View Related
Mar 10, 2005
How can i refered to a table value through a form?
Thank you!
View 5 Replies
View Related
Oct 11, 2005
Hey everyone
This issue is holding me back now on 2 areas of my project :(
I need to know correctly how to reference a subform in a query.
Can someone please give me a working example for this:
main form: training courses
sub form control: course_dates subform control
sub form: course_dates subform
text box: course_date
I have tried:
[forms]![training courses]![course_dates subform control]![course_dates subform]![course date]
in the criteria box, but every time the query runs i get a parameter box "forms!training courses!course_dates subform control!course_dates subform!course date" asking for the info.
Seriously I am totally stuck on this and i think all i need is one perfect example... please help!!!
View 3 Replies
View Related
Feb 17, 2005
I'm sure this is simple, but I can't find it anywhere...
How do I refer to an instance of a form using its key value?
For example, I have a collection 'colForms' and two forms in that collection with the keys 'Key1' and 'Key2'. How do I refer to the instance that has Key1 in code (for exampe, to close or requery the Key1 instance of the form from another form)?
Thanks in advance,
David
dminstance
View 1 Replies
View Related
Mar 3, 2015
I have a table with 6 columns (Field1, Field2...) and a primary key called ID (1,2,3,....).In the first column (Field1) I want to retrieve the value from the 6th one (Field6) but from the above row. Something like this:
Field1 (ID2) = Field6 (ID1)
Field1 (ID3) = Field6 (ID2)
How can I translate this into a formula?
View 2 Replies
View Related
Feb 6, 2006
Hi
I have been refreshing myself with SQL on Access 2002. All was going well until I got to the BETWEEN...AND operator. Using the Northwind sample database I was writing the query on the employee table to select all the columns between 'Fuller' and 'King' :
SELECT * FROM Employees
WHERE LastName
BETWEEN 'Fuller' AND 'King'
However this only brings back the two rows for 'Fuller' and 'King' whereas I would expect at least 5 rows or more depending on whether access would count 'Fuller' and 'King' as inclusive.
Have had a look on the microsoft office help page but seem to be doing everything correct so I am wondering why it still doesn't work? No doubt simple but its concealed in mud at the moment. Any help apreciated.
cheers
View 13 Replies
View Related
Apr 20, 2008
Hi again
I've done some searching on this question and it seem everyone is pointing to the DateAdd function, so here is my current problem.
I have a date/time field called SponsorshipContractDate. When a contract is signed the date is entered. I need the system to calulate the renewal date for the contract which is alway 1 year ahead.
The DateAdd function works only if I hard code at date into it e.g.
DateAdd ("yyyy", 1, "01-Jan-08")
But as contracts are signed throughout the year this just doesn't work so I tried this:
DateAdd ("yyyy", 1, "SponsorshipContractDate") but the table won't save and this is abviously not right. In my head it makes sense but I don't understand how to get the formula to look at another field during it's calculations
Am I using the wrong function?
I will keep looking around.
Thanks heaps
View 4 Replies
View Related
Jan 17, 2007
Access 2003.
I was just wondering if there was any way to refer to a calculated field in the same query.
For example if the first calculated field was - Total: ([Quantity])*([Price]), could you add another calculated field - Inc Tax: ([Total])*1.175.
At present I am having to type the whole formula in the calculated field again which seems to work for some queries, but not for others, no matter how I fiddle about with the syntax. The other way is to create another query and refer to my previous query. Both these methods seem extremely cumbersome and I was wondering if I have missed something with referring to a prior calculated field.
The query above is just an example, my query formulas are actually fairly long and for editing purposes it can be difficult to correct them.
View 4 Replies
View Related
Jun 8, 2005
Hello - I have a form with a txtbox that shows a date. I need the querry to refer to that date as selection criteria. I have the following in the criteria of the query: =[forms]![frmUpdatePayments]![txtDate]. I know the problem is I need # at the beginning and at the end of the date, but how do I do that?
View 1 Replies
View Related
Feb 17, 2005
hello. can i refer to a single record in a detail section, and not all of them? for example if i use something like this (after update in field1):
if me.field1 = 0 then
me.field2.enabled = false
any single field1 equal to zero will disable ALL of the field2's. i would like this to work within each record independently.
View 2 Replies
View Related
Nov 2, 2006
I have a form named frmtestpkg which has a subform named pkgsubform. The control the subform is in is called pkgsubform1. I have written a macro which works very nicely to hide or show the field [Days2process] if I attach it to "on current" on pkgsubform and open pkgsubform as a form. If I try to open pkgsubform as a subform I get a message stating "The object you referenced in the Visual Basic procedure as an ole object isn't an ole object."
How do I change my macro to refer to the form and controls as a subform?
my Macro looks like this:
condition: [Forms]![Pkgsubform].[CrPkgStatus]<>"Accepted"
Action: SetValue
Item: [Forms]![pkgsubform]![Days2Process].[visible]
Expression: No
condition: [Forms]![Pkgsubform].[CrPkgStatus]="Accepted"
Action: SetValue
Item: [Forms]![pkgsubform]![Days2Process].[visible]
Expression: Yes
View 2 Replies
View Related
Nov 14, 2006
Still beating my head on the wall. I'm sure it is simple but I NEED guidance.
I've made a macro to show a date field when the "Yes" option button is selected and hide it when the "No" option button is selected. I first created it for the form to act on its own --> and it works. Now I want to use that form as a subform in the form [frmTestPkg]. I am having problems figuring out how to reference it properly as a subform.
Here's my macro that works when I attach it directly to my form:
Condition:[Forms]![frmsubcruiseplan]![CrPlRecvdNo].[OnGotFocus]
Action: SetValue
Item: [Forms]![frmsubcruiseplan]![CrPlSubmDate].[Visible]
Expression:No
Location: "On Got Focus" Event for the option button "No"
Condition:[Forms]![frmsubcruiseplan]![CrPlRecvdNo].[OnGotFocus]
Action: SetValue
Item: [Forms]![frmsubcruiseplan]![CrPlSubmDate].[Visible]
Expression:Yes
Location: "On Got Focus" Event for the option button "yes"
I have followed the pattern provided previously of
Forms![main form name]![subform control name].Form![control name]
but cannot get it to work -- obviously messing up somehow.
The reference I tried in the condition looks like this
[Forms]![frmTestPkg]![frmsubcruiseplan].[Form]![crplanrecvdNo].[OnGotFocus]
--> and with or without the setvalue information included I get a "The object you referred to as an OLE object isn't an OLE object" error.
Perhaps I am not identifying the subform control name properly? Or maybe I should be referring to the "Cruise Plan Recvd Option" instead of the individual control boxes (but it worked as a form)? Please spell it out for an idiot, what this is supposed to look like. Many thanks!
View 1 Replies
View Related
Feb 12, 2014
I have a report with several subreports. I need to total the subreports onto the main report. How do I refer to the control on the subreport?I know that with a form / subform I would use: Me!Subform1.Form!Controlname.But simply replacing 'Form' with 'Report' doesn't seem to work.
View 1 Replies
View Related
Sep 12, 2014
Actually in a powerpoint slide, I am having a set of 31 shapes having their names as numbers from 1 to 31.
How to refer by its name?
By hardcoding I refer it like this:
activepresentation.slides(1).shapes("1").someprope rty = somevalue
How to do it in a loop?
Code:
for i = 1 to 31
activepresentation.slides(1).shapes(i).someproperty = somevalue
next i
The above code will refer the shapes only by the index. But the shapes are not having index and name as same.
View 9 Replies
View Related
Feb 28, 2015
know if there is a way to use a string concatenation to refer to a control name. eg. Referring to Control1, Control2, Control3, Control4, etc using something like Me.["Control" & "1"], Me.["Control" & "2"], etc
View 6 Replies
View Related
Sep 26, 2005
I am new to this forum, so forgive me if this question has been asked before
I needed exact information about the way the 'like' operator works, so I pressed F1, typed 'like' in the "Answer Wizard" and was told to "rephrase my question". :eek:
The index was slightly more helpful as it obviously contains 2 topics with 'like_operator', but choosing them does not reveal anything. :confused:
Where can I find info about such things?
I also need to use an operator called 'contains' which I have used when working with SAS, but appearently it does not exist in Acccess or it has another name. Has anybody heard about it?
View 2 Replies
View Related
Nov 15, 2005
Hi guys!
It's unknown for me why Access hasn't got MINUS implemented and Unmatched Query Wizard doesn't help me much. So I'm wondered if anyone had to confront the following task:
Table1
Book Agent
----------
b1 a1
b2 a2
b3 a3
Table2
Book Agent
----------
b1 a1
b3 a3
The problem is I have to eliminate duplicates but I need to find unique row, which is Book and Agent. From my example it's row with (b2 a2). I tried using
Select * From Table1
Where (Book, Agent) Not In (Select Book, Agent From Table2)
didn't work
I also tried EXISTS
didn't work
Unmatched Wizard compares only one field, not two.
Any comments welcome, thank you
View 2 Replies
View Related
Jan 10, 2007
I have an invoice-line table with records for every line on invoices. I'm trying to return all the lines associated with certain invoices, excluding all lines with "FREIGHT" in a line item field. I created a query that lists all the invoice numbers for which I want to display invoice lines for. I created a new query with the invoice line table linked to the invoice number query by invoice number (a one to many relationship). There are about 1400 results from this query. By making the criteria of the line item field "FREIGHT" and running the query, I can see that there are 81 "FREIGHT" records that I ultimately want to exclude. However, by typing NOT "FREIGHT," it appears that not only are the "FREIGHT" line item records excluded, but also records with a blank (null)line item field are excluded, and I end up with about 650 results. What's going on here? Why is the NOT "FREIGHT" critera also excluding null records? I don't have any other criteria specified in the query. :confused:
View 5 Replies
View Related
Apr 9, 2007
I have an expression that I'm trying to build into a totaling field in a report. There are two types of items being tallied into this total; 1 is a flat amount, the other is a calculation of # of men * # hours * rate. I already have an expression that works for the first level of calculating:
=IIf([Type]="Lawn Maintenance",[LMAmt],[# hours]*[# men]*35)
Note: [LMAmt] holds a flat amount
I wanted to add, after the [Type]="Lawn Maintenance",[LMAmt] an "or" somehow which would basically state or [Type]="Dumping Charge",[Expenses]
Note: [Expenses] is also a flat amount and all other [Type] codes are determined using the calculation below:
if [Type] is not = to "Lawn Maintenance" or = to "Dumping Charge", THEN [#hours]*[# men]*35
Hopefully I explained myself well :confused:
Thanks in advance!
vnorcliffe
View 2 Replies
View Related
Apr 26, 2007
I have a select query that has filenames listed. I would like to use the Like Operator to select only those filenames with certain bits of string.
For example: In the Criteria area of a query Like "*Defense*" selects all filenames with the word Defense successfully.
However, I would like to select the key word from a combo box and use it in the Like expression.
For example:
Like "* '&Forms![View Selected Plays]![Play Type]&' *"
The code above does not return any results even if the term Defense is selected in the combo box.
I am sure this is a quotes, single quote, *, % type problem, but every combination I try yields no results.
Thanks.
View 2 Replies
View Related
Aug 16, 2006
Hi!
I've developed a form to be standalone. It's based on a query with filter like this:
Like "*" & [Forms]![myForm]![Fltr1]
(The Fltr1 is a combox value.)
Now when i place the form "myForm" as a subform in another form (FormMain), the query does not give me any data.
How do i refer to the filter from the query??
Any help will be much appreciated!
thanks ;)
View 2 Replies
View Related
Oct 10, 2006
I have a main form with a subform. On a subform I created a combobox which I want to populate with ClassIDs that match the main forms Individual. I know the criteria in VBA for the above would look something like this:
"SELECT tblClassesAttended.ClassID FROM tblClassesAttended WHERE blClassesAttended.IndividualID=" & Me.Parent!IndividualID
but when I type such statement in the row source of the control it does not work. What is the correct way of refering to the parent form when typing the SQL in the row source?
BTW. I cannot use the main form's name
View 3 Replies
View Related