Using "Like" Expressions And Referring To External Forms.. How?

Apr 6, 2006

I know that to refer to a field in a different form we do sthing like this Forms![Products]![Product name] (for example). But when i try to use it in a query under criteria with the "Like" expression it treats it as normal text.
What i basically need to do is have a form used as a search facility where one enters information then clicks view (which is a button that opens a datasheet filtered from the query which should have its criteria referring to the information entered in this form).
What i did:
Under the "product name" criteria in the query i entered:
Like (*Forms![SearchForProduct]![Product name]*)
When i press enter it automatically puts the inverted commas and treats it as normal text and does not refer to this form. Anyway, i created a form from this query called "Product search results" then inserted a command button in the "SearchForProduct" form (next to the "product name" field) which opens up "Product search results" . It does not work at all, because as i said before it does not refer to the form. This way of referring to another form worked with many other queries, but with the "Like" expression it doesnt work.

If someone knows an alterantive way of doing this please help me (even if it involves visual basic).

thanks

View Replies


ADVERTISEMENT

Modules & VBA :: Referring To Forms Objects Using Variables

Sep 30, 2013

I have a simple date stamp that works great in a private sub within a form. (error handling removed for clarity)

Code:

Private Sub btnDateStamp_Click()
' UserInit is global variable
Me!Notes.SetFocus
Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & UserInit & _
" -" & vbCrLf & Me!Notes

[code]...

I am rewriting it as Module function that is Called from various forms, to save space. The function receives the parameters varFormName and varControlName. I wish to write the results of the function back to a memo field on the form.I am stumped at the get go by the need to refer to the Forms controls with a full reference instead of the Me command.

Code:

Function DateStamp(varFormName As String, varMemoName As String)
'varInitials, varFormName, varMemoName are global variables
Forms!varFormName.Controls!varMemoName.SetFocus ' Error here
'Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & varInitials & _

[code]...

how to refer to the forms control's with their full reference, from within the Module's function, the rest will fall into place.

View 3 Replies View Related

Forms :: Referring To Text In A Table On Subform

Mar 3, 2015

I have a form with a subform that has a table on it. The subform table is a price list with the fields Description, Details (which is hidden as it's too big for the table) and Price.

I want to be able to double-click on a chosen item from the table to display a pop-up showing the same details but with the Details field shown. I have the pop-up in place but I am struggling with displaying the chosen information.

How do I reference the fields on the chosen line in the table?

View 6 Replies View Related

Forms :: Referring To Form And Subform Combo Box

Jul 21, 2014

I have a form named frmMain that contains five buttons that lead to subforms, one of which is named frmDeceased.

In frmDeceased, I needed to create a combo box that relied on selections from the combo box before it. I was able to do this successfully in frmDeceased, but then today when I opened the database and opened frmMain, I realized that the query fails when frmDeceased is opened via frmMain. It works perfectly if I just open frmDeceased directly.

The first combo box is ROHE and the second is Iwi (which is dependent on the Rohe selected).

The query for Iwi has this criteria: Forms!frmDeceased!cbo_ROHE

When I open frmDeceased through frmMain, I get the 'enter parameter value' message showing "Forms!frmDeceased!cbo_ROHE".

I tried changing this query to: Forms!frmMain!frmDeceased!cbo_ROHE, but it didn't work.

View 14 Replies View Related

Help With Expressions On Forms

Jul 6, 2005

Hi all, I'm writing a database basically as a favour to someone. I'm a sql analyst/programmer so my access and vba skills are a little limited and I hope someone can help me with a problem I have.

Part of one of my forms is a flow chart style set of Yes/No questions and the user answers each question. For each question I have created a (hidden) text box which calculates a score (5 for no, 10 for yes) which I have done with a IIF expression in the Control Source of the text box. These are then totalled to give an overall score.

This score is then used to calculate a grade (A or B) and a percentage score using the same IIF method in the control source.

What I want to do though, is use this grade and percentage and write it to the individual record as data in the table - to use in reports and such like.
Is there any way I can do this? I've tried a few bits of VBA but to no avail. Is there a way that this can be done? Or have I approached this in entirely the wrong way??!!? :confused:

Any help would be greatly appreciated!

View 2 Replies View Related

Expressions In Forms

Nov 24, 2005

Hi,

Is there a way on Access that when a total is calculated using an expression on a form that it could update the table itself with that total?

Thanks for any help!


Roly

View 1 Replies View Related

Forms :: Textbox On Main Form Referring To Subform Control

Aug 14, 2014

I have a form with a subform which resides in a tabbed control. In that subform, I have a textbox in the footer that sums values in the detail section of the subform.

I have a textbox on my main form that should display the same data that is in my subform footer textbox, but it is giving me the #name? error.

This is the expression in my subform footer textbox (which returns the correct result):

TxtSubtotalHQPCalc -
=Sum([ActualHQPCalc])

And the expression in my main form textbox (which returns #name?):

txtActualHQPValue -
=([subfrmHQPProject].[Form]![TxtSubtotalHQPCalc])

I have verified that my subform name and textbox names are all accurate. This is very frustrating because I am using this exact same method in a different database with no problems!

View 3 Replies View Related

Forms :: Expressions Not Working On 2010 Form Controls

Aug 13, 2013

I've just started using 2010 and, unlike previous versions, the expressions that I've put on controls in a form are not working. Is there a setting that has to change that's new to 2010?

View 5 Replies View Related

Forms :: Referring A Form Inside A Form Using Access 2007

Mar 10, 2013

I have a Form called X which contains a subform called Y. I have placed this Form inside another form called Z.

There is a CommandButton which when clicked must refer to the Subform. How do I do this?

I tried using [Z]![X]!Y, Form_Z.Form_X.Y, [Z]![X].Y but it throws an error saying the form name has been misspelled ...

View 4 Replies View Related

Forms :: Reformat A Field To Match External Data

May 29, 2013

I am attempting to use some external data to populate fields in my DB. I would like to reformat the ProductID in my DB to match a ProductName coming into my DB. We have many products that have 2 pieces. If the product does have two pieces, the external database has two ProductNames that look like this:

0000967
2000967

I would like my database to be able to pull information for each of these 2 part products (they will be displayed as one product in our DB, never to be seperated). I have a form that gives the exact measurements of the first piece by using the ProductName and matching my ProductID (0000967). I would now like to write a little VBA to populate some fields on the forms that are pulled from 2000967.

something like:
Forms!Product!txtField2 = DLookup("[FieldName]", "TableName", "[ProductName] = Forms!Product!ProductID")

The issue is that I need to only get the trailing 6 digits of my ProductID and add a 2 at the beginning. Is there a quick Format syntax I could use to accomplish this?

View 14 Replies View Related

Forms :: Cannot Open External App Using Shell In Access 2013

Aug 19, 2014

In previous versions of Access (i.e 2003 and prior) I could use the following code in the On Click event of a form's command button to open an external file:

Dim stAppName As String
stAppName = "C:Program FilesCadroTransPost PlusTransPostPlus.exe"
Call Shell(stAppName, 1)

However, I'm now using Access 2013 and it wont allow me to use this anymore, it gives me the following error:

Runtime Error '5"'
Invalid procedure call or argument

Why this doesn't work in Access 2013?

View 1 Replies View Related

Referring To A Combobox Value

Jan 4, 2005

hiya..how do i refer to a combobox value from a criteria in a query??
i.e. criteria for a field in query = combobox value in a certain form

View 2 Replies View Related

If Statments And Referring To Other Tables

Sep 25, 2007

I am new to access and am having troubles figuring out if statements. I want an if statement in a table that says if column 1 = "whatever" then column 2 = "YAY" else column 2 = "NO".

How would I apply this to a table?

Also I have a table that has one column it is a list of codes. In another table there are 2 columns column 1 has a code i want column 2 to say if column 1 code is found in the list of codes from the other column the put "MATCH FOUND"

Thanks,
Mike

View 12 Replies View Related

Referring To The Data In Rows Below

Sep 27, 2007

Column A Column B Column C Column D
1*010101001000000 CF 5
010101002000000 RF
010101002000000 RF
010101029000000 CU
1*010101001000000 CF 10
010101351010000 RF
2*010101354000000 CF 11
2*010101354000000 CF 13
010101358000000 CY
1*010101001000000 CF 5
010401328100000 CF


NOTE in the actual data won't be there it is just to show you what I am referring to.

Is there any way in another column in a query to say if Column A repeats itself somewhere else in Column A AND if those two that are repeated both have a "CF" code add column C (which is just an amount for each number)

So for example in this data there are 2 numbers that repeat themself that have CF codes. For these I would need to total them in column D for the first number resulting in:


Column A Column B Column C Column D
1*010101001000000 CF 5 20
010101002000000 RF
010101002000000 RF
010101029000000 CU
1*010101001000000 CF 10
010101351010000 RF
2*010101354000000 CF 11 23
2*010101354000000 CF 13
010101358000000 CY
1*010101001000000 CF 5
010401328100000 CF


Any ideas?

Thanks,
Mike

View 14 Replies View Related

Referring To Columns In A Combo Box ?

Jan 26, 2006

Hello, I am using an IIF statement in my SQL criteria, and was wondering "if" it was still possible to reference a column within a combo box... here is one iif statement

Like IIf(IsNull([Forms]![fSampleSearch]![cboCustomerName]),"*",[Forms]![fSampleSearch]![cboCustomerName])

I want to refer to the third column of cboCustomerName... How would I do this ?

View 8 Replies View Related

Label Name Referring To Subform

Jul 3, 2006

Just a quick question, I can't seem to get this right (as usual :confused: )

I have a form and I want the label in the header to display the text from a field in a related subform. I have tried the following syntax to no avail:
=[Forms]![sfrmCompanyName]![LastName]

Any suggestions

Thanks in advance

Nicolas

View 2 Replies View Related

Referring To A Subform Control

Nov 15, 2004

I know how to refer to a control on a form by using [forms]![formname]![controlname], but can anyone help with referring to a subform.

I have a subform called subPrograms, on which is a combo box whose contents need to be filtered depending on the selection from another combo box on the main form.

The combo box on the main form is cboDivisions.
The combo box on the subform is cboPurchasers
Main form is called frmMain
Subform is called subPrograms

The user is supposed to select a Division, and then depending on that selection the contents of cboPurchasers will change to only show those that are within that same division.

I would also like to know how to update the cboPurchasers when the cboDivision has been selected? Can someon help?

I hope that this is enough info.

View 2 Replies View Related

Referring To Different Record Other Than Current

Dec 8, 2004

Hello,

I'm trying to write a formula/program that will look at a table, look at the date of each record, and sort out and group the records by week (in this case, Sat.-Friday). However, in order to do this, I'm assuming that I must be able to have the program look at, not only the date of the current record, but also the date of the records before and after the current one. What would be the easiest and most efficient way of writing the references? Thanks!

G

View 1 Replies View Related

Referring To The Application Icon Using Code

Jan 2, 2008

Hello all...Happy New Year!!

I have obtained some VB code shown below which adds an icon to the windows task bar as I intend to put some additional code behind this that displays messages near the clock when something happens in the database.
The problem I have is that the code does add an icon but the icon is literally blank. i.e. it makes an additional icon space but does not display any picture.
The code is not actually for VBA so I need to tweak it. I am struggling with telling it which icon to display. Does anyone know how to refer to the application icon using code??

The code I am working on is: (there is also a module but I will post this if you need it.)
-------------------------------

Private Sub AddTrayIcon()

Dim nid As NOTIFYICONDATA

' nid.cdSize is always Len(nid)
nid.cbSize = Len(nid)
' Parent window - this is the window that will process the icon events
nid.hWnd = frmSystray.hWnd
' Icon identifier
nid.uID = 0
' We want to receive messages, show the icon and have a tooltip
nid.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
' The message we will receive on an icon event
nid.uCallbackMessage = 1024
' The icon to display
nid.hIcon = frmSystray.Icon
' Our tooltip
nid.szTip = "Always terminate the tooltip with vbNullChar" & vbNullChar

' Add the icon to the System Tray
Shell_NotifyIconA NIM_ADD, nid

' Prevent further adding
cmdAddIcon.Enabled = False
End Sub

Private Sub cmdAddIcon_Click()
AddTrayIcon
End Sub

-------------------------


This is the code that is the problem. I dont think VBA has this function so I need to tell it where to find the .ico file I use for my database.
Thanks folks.

View 2 Replies View Related

Referring To Form By Using Its Index Number

Aug 23, 2006

How can I refer to a form by using its index number? Also how can I retrieve an index number of a form?

(I'm opening multiple instances of the same form and read that the only way to refer to those instances is by using their index number. I found some solutions that use hWnd as well but I can't get any further support on it as far as referring to a form by using the window handle so I'm trying to capture and then use the index number)

View 4 Replies View Related

Modules & VBA :: Referring To Tab Control On Sub Form

Jun 9, 2013

I have the following setup:

A main form - named [formMain]
On [formMain] I have a tab control - named [tabMain]
[tabMain] has 3 pages named [pageOne], [pageTwo] and [pageThree].
On [pageThree] I have created a subform named [formSub].
On [formSub] there is a tab control named [tabSub].

Now what I would like is to make [tabSub] (in)visible if the user switches from [pageOne] or [pageTwo] to [pageThree].

Code:
Sub tabMain_Change()

How do I refer to [tabSub] from within this subroutine? I am trying something like:

Code:

Forms![formMain]![pageThree].Form![tabSub].Visible = False

but it is not working. What should be the correct way?

View 2 Replies View Related

General :: Referring To A Field That Is Not In A Form

Dec 3, 2012

I would like to know if it is possible to refer to a field even tho it is not in a form, i.e.,

PHP Code:

strSql = "UPDATE tblItems " & _ "SET StockQTY = ([StockQTY]+1) " & _ "WHERE ItemsID = " & [ItemsID] & "" 

The [ItemsID] is actually on the form as a txt box. but i dont really need it there for any other purpose other than the vba above.

In the form i have a field that is in the form as a txt box that has a relationship to the ItemsID. i have attached a image of the relationship.

The field that is in the form is tblOrdersItems.OrdersItemsID and i also have tblItems.Items. so rather than adding another meaningless txt box to the form(ItemsID) i would like to be able to use the relationships to get the correct ItemID ...

View 1 Replies View Related

Delete Fields Referring To Field Number

Aug 5, 2006

I need to trim a lot of tables. Is it possible to delete table fields with reference to the field number instead of field name?

The command 'tblMyTable.Fields.Delete ("FieldName")' takes a string (field name) as input. I rather like to - in a loop - delete say,

Sub DeleteFields()
For i = 40 To 60
tblMyTable.Fields.Delete Field(i) ' Not correct syntax
Next i
End Sub

thh

View 2 Replies View Related

Problems Referring To Combo Box For Default Value In Subform

Nov 30, 2006

I want my subform to allow additions. I would like the default value for one of the fields in the subform to be the value chosen in the combo box that is used to select which records are shown in the subform. The row source for the combo box is

SELECT tblLicensee.LicenseeID, tblLicensee.[Licens#] FROM tblLicensee;
where LicenseeID is the key field and Licens# is what is displayed.

If I refer to the combo box for the default value for that control on the form…
=[Forms]![frmFindRecord]![Combo37]

the key value (LicenseeID) is entered as the default instead of the value displayed in the combo box (Licens#). How can I set the default value to record the Licens# instead?

View 1 Replies View Related

General :: Combobox Not Referring To Correct Field

Oct 22, 2014

I have a form which contains fields from my main table and also has a subform containing a query based on a filtered list of my main table.

I have a combobox on the form to select a name and pass it to the query to filter on.

The list of names is in a table called tblnames which has 2 fields, name and ID. I have linked the ID field on this table to a field called nameid on my main table which is a numeric field (and that allows be to select a name from a list when I enter data into my main table.

The xox is unbound, control source empty and row source set to tblname.

The combobox is only showing a list of numbers (I assume they are the id field from tblname). Yesterday I had the list of names showing and I checked a backup and the only difference I can see is the row source property refers to the name field in tblname but I don't know how I got it there. When I click on the list box for row source I only get offered a list of my objects.

View 10 Replies View Related

Modules & VBA :: Referring To Calculated Field In A Recordset

Nov 22, 2014

I am trying to use a calculated field in a recordset but I am having problem with the script trying to compile.

my record set is

Set rstPrice = db.OpenRecordset("SELECT Period_desc, Price, Round(Price/7,2) AS Daily_rate FROM qryPropertyPriceList WHERE [Our ref] = '" & rstProp![Our Ref] & "' And [Year] = " & rstProp![Next year price base] & " Order By Sequence", dbOpenSnapshot)

The calculated filed I have added in is Round(Price/7,2) AS Daily_rate

If I let it run just with this it runs fine.

and then I try to use this calculated field:

Do Until rstPrice.EOF
Temp = Temp & rstHTML!html35 & rstPrice!Period_desc & rstHTML!html36 & rstPrice![Price] & "-" & rstPrice![Daily_rate] & rstHTML!html37
rstPrice.MoveNext
Loop
rstPrice.Close ' Tidy up
Set rstPrice = Nothing

They it stops running and it all seems to be because of the Daily_rate field

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved