Queries :: Pass TempVar To Query That Is Selected From Previously Opened Form
May 23, 2013
I'm trying to create a query that supplies a form with data. I want to pass a TempVar to the query that is selected a from previously opened form.The TempVar is setting correctly and I can see if this if I place a textbox (NewCID) on the form showing the TempVar. The problem I have is displaying on the records according to that TempVar. If I set the query manually, i.e. "|Test|" then records are displayed but if I use the TempVar, which also displays |Test| then no records are brought back.
think it's something do with the vertical bar and that fact the field I'm searching on is a memo field, both of which I've no control over. I also have to use the Like statement because of this.Here's the query that works...
SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like "|Test|"
and the one that I want to use, that doesn't...
SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like [TempVars]![tmpvarCID]
I've even tried referring to the textbox instead of the TempVar, i.e.
SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like [Forms]![AssetsCID]![NewCID]
but that doesn't work either.
View Replies
ADVERTISEMENT
May 9, 2015
I have two subforms in a tab formation sitting on a main form. They can both open up a single popup form (via a button) and that popup form is opened via openargs with the autoID field.
What I need to do is pass back a value on the popup forms [On Unload] event to the subform which opened it.
As the popup form is Modal, the subform which opened it can't be changed.
Am I right in thinking I can pass back the value to the form which had previous focus?
Previously, to pass a value from a popup form to a single form I've been using
Code:
If CurrentProject.AllForms("MyForm").IsLoaded Then
do this
else do this
end if
But in this instance, how do I code the On Unload event in which to tell Access which form opened up the popup form, and pass a value back to it?
I'm guessing
Screen.PreviousControl.SetFocus
has something to do with it?
View 14 Replies
View Related
Nov 14, 2013
The Query
'SELECT Count(clubbox) AS MTSingles
FROM moves WHERE (((moves.cmrdate)>[Forms]![CPanel]![Text44] And (moves.cmrdate)<[Forms]![CPanel]![Text46]) AND ((moves.driverid)=[Forms]![CPanel]![Text38]) AND ((moves.move)=35) AND ((moves.clubbox)=32));'
returns about 60 records, how do i assign the results to a tempvars
View 9 Replies
View Related
Jul 7, 2014
I am making a database, but lets say I have 12 locations and have say between 2-100 named people at each location.
I want to be able to link 2 databases together.
I can use lookup wizard to select either a location, but I also want access to display the names at ONLY the location previously selected (IE: Paul and Bert are in Brazil, Steve and Carl are in Cuba, I want once Brazil is selected only Paul and Bert to appear as options). I'm sure it's fairly basic but a having a little trouble with it, and not knowing the technical terms is making it hard to look up.
View 1 Replies
View Related
Jan 30, 2008
All -
For the life of me I can't get the Multiselect Listbox to correctly pass along all of the item selections to a Query which a form is based on.
I've been up and down the forum, and I can't figure out what piece of code to use and how to use it successfully.
I've been able to get a string created using the example posted here (http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=47909) and it's in the format of "54,67,89,100" etc.
Public Function
Public Function fMultiSelect(ctlRef As ListBox) As Variant
Dim Criteria As String
Dim i As Variant
' Build criteria string from selected items in list box.
Criteria = ""
For Each i In ctlRef.ItemsSelected
If Criteria <> "" Then
Criteria = Criteria & ","
End If
Criteria = Criteria & Format(ctlRef.ItemData(i), "0000000")
Next i
fMultiSelect = Criteria
gMultiSelect = Criteria
End Function
Call:
Call fMultiSelect(Forms!frmPreSPIPComp!lstProjects)
I now need to pass that string to a Query. Once it's been passed to the query, I can open the report based on it.
Essentially I have a button that will perform the string creation, and I would then like to open a report. I want to base the report off of a query and then have the query use Criteria to dwindle down the report.
Am I missing something here?
The long explanation:
I have a single form that allows for the selection of the report. Once the report is selected, certain fields appear that allow for certain criteria to be selected (ie. Class Name, Multi-Select Class Name, Student Names, Multi select Student Names, Dates, etc.)
Once the report has been selected and the criteria set, a user hits a single button that runs the specific report.
Any better ideas of how to set this up. The reports will ultimately be basing their criteria on what the form has in all of it's unbound fields.
I also have a table that specifies the Display Name, actual Report Name for the button to figure out what report to run.
Bottom Line. I want to use a Listbox to filter a report. If I can use a query to base the report off of even better. I don't want to create the SQL in VBA.
Any ideas? Thanks!
View 5 Replies
View Related
Apr 5, 2013
Access 2003
Excel 2003
I have a routine that exports the results of a query to an Excel file. Is it possible to input the formula into the query so that the Excel values calculate?
This is the formula I am trying to pass to the "AZ" column of the Data tab
Code:
MyCalc::"IF(T2="","0",TODAY()-T2)"
View 1 Replies
View Related
Dec 4, 2006
I have two forms - Notes and JobLookup
Notes contains a number of text boxes for entering data, one of them being for Job No. Beside it is a link to the form JobLookup. This form contains a simple listbox that lists all the job no. Is it possible to pass the selected job no from this list to the text box on the Notes form?
Hope this makes sense :)
Michael
View 3 Replies
View Related
Feb 25, 2014
Picture, if you will, a table with multiple fields, each of which contains the date of a certain action in the process tracked by each record. I have a standard report format that will be used to view the progress of the actions. I want to be able to sort the report - on demand by non-technical users - by whichever date field they choose.
I've created a form with a combo box that is linked to a table with the name of each field in the source table. A Macro has been configured to open the form when the report is opened, which will prompt for the selection of the sort field. That value is then captured into a TempVar.
When the user clicks OK control passes to a procedure in a module that executes a SELECT statement (SQL) that configures the Query that is used for report generation. The "ORDER BY" portion of the statement needs to be modified with the name of the sort field desired. If the statement is hard coded as, for example:
...ORDER BY Main.[Initiated Date] DESC;
it works fine. I want to use the value of the TempVar to provide the name of the date field (ex.: [Initiated Date]), but I can't determine the correct syntax to get the statement to accept it. Concatenating doesn't seem to work, and I've searched high and low for hints on the web. Here's one version of what I've tried (and which fails):
"...ORDER BY Main." & [TempVars].[SortParm] & ";"
The error returned by the above version is: "Object doesn't support this property or method"
(SortParm is the name of the TempVar, and it is correctly populating, and keeping, the value I need from the form.)
View 3 Replies
View Related
Sep 11, 2013
I am trying to pass the results of what is selected in a list box to sql through an ado statement, when i select one result i can pass the value with no issue, when i select multiple item i get a run time error incorrect syntax near ';' i am guessing it is passing the data as a csv to sql and the where statement does not like that as criteria but i am not sure how to handle that either in vba or on the sql side.here is my vba code from access
Private Sub Command49_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strItems As String
Dim intItem As Integer
For intItem = 0 To List45.ListCount - 1
If List45.Selected(intItem) Then
strItems = strItems & List45.Column(0, intItem) & ";"
End If
[code]....
View 3 Replies
View Related
Feb 13, 2014
I am after getting an access 2003 database to look after and it contains SQL pass through query's. The database is a front end to a MS SQL server database with a connection string that is contained in a module.
I believe the SQL pass through queries are connecting to the same database as the rest of the application and somehow is using the connection string in the module. However I cannot find how that is configured on the SQL pass through queries.
Most documentation on the net seems to point at using ODBC to connect slq pass through queries to outside databases but I don't think this is the case. There are not Odbc sources set up for the database I am look at.
View 8 Replies
View Related
Feb 10, 2014
In a table of a SQL-Server 2008 I have a fieldname "Alter", the German word for age.
When sending a PT-qry to the server I get an error "Incorrect syntax near the keyword 'Alter'"
Even when I try to set "Select tblmytable.Alter as Age" I get the same error.
To change the fieldname is almost impossible, as there is to much code to change.
View 3 Replies
View Related
Feb 24, 2014
I made multiple pass through queries that receive their data via an ODBC link which is established. Currently the username and password is entered seperately in every query but I was wondering if it is possible (and how) to make both look for the values in a table (OR somewhere else if possible) for these values. The following code (with edited information) is used in all queries.
Code:
ODBC;DSN=DSNNAME;Driver=Firebird/InterBase(r) driver;Dbname=Database.FDB;CHARSET=NONE;PWD=Password;UID=User;
The reason that I would like to do this is to ensure that the user can change it easily.
View 3 Replies
View Related
May 9, 2005
I don't know if this is thebest place for this, but here goes....
I have an Access FE using MYSQL 4.1 BE. I have several forms and PassThrough queries (using MYSQL syntax not supported or available in Access).
How can I use form field values to use as criteria for these queries?
FOr example, in a pure Access database. I may have a form 'Employees' with a text box 'EmployeeName'. THen have a query....
SELECT * FROM tblEMployees WHERE EmployeeName = [Forms]![Employees]![EmployeeName]
If I were to add this variable to my pass-through queries, it errors. How can I do the same thing, passing my form fileds to an Access Query? I am trying to do this right in the SQL view of the queries, not in VBA or Macros or anything.
Thanks,
Scott
View 2 Replies
View Related
Feb 23, 2006
I have developed some complex pass-thru queries in Access, looking at DB2 data. I am hoping to be able to make these queries 'prompted' for easy use for my less technical colleagues. If these were developed in IBM's QMF tool, I would build the prompt like &MemberID, for example, if I wanted the user to input a value for Member ID. Access pass-thrus don't recognize this, and it throws an error. Anyone have any ideas on how I can do this?
Thanks in advance for any help...
View 1 Replies
View Related
Jan 10, 2014
I get a result set from a pt qry from a sql server 2008 in vba. Me.Total is an unbound field in the report foot( correct translation of german "Berichtsfu"??)
Private Sub Berichtsfu�_Print(Cancel As Integer, PrintCount As Integer)
SELECT SUM((DATEPART(hour, Calctime) * 60 + DATEPART(minute, Calctime)) * Price / 60) AS TtlPrice ...
Set rs = CurrentDb.OpenRecordset("qryPT_TtlPrice")
Me.Total = rs("TtlPrice ")
On the access report I can format me.Total as currency, decimal, integer whatever I want (unless it makes no sense exept currency) and it works.
but
SUM(((DATEPART(hour, Calctime) * 60 + DATEPART(minute, Calctime)) * Price/ 60)* (case when CompanyID=1 then 1.66 else 1 end)) AS TtlPrice
The detail should be multiplied with 1,66 when the record belongs to company 1, for all others ist remains the same. In the Management Studio the results of both looks similar, same in the debug window of VBA editor, but I cannot format the result or lets say, the formating is wrong for the second example.
Neither in VBA
Me.Total = format(rs("TtlPrice "), " 0.000,00") or
Me.Total = format(rs("TtlPrice "),"0.000,00")
nor in the report int the properties of the field I can avoid this result: in the debug window of access the result looks OK, for example 29555.670000 (don't know where all the 0 come from), which should read as 29.555,67. But on the report the result with formated curreny in field property (currency, 2 decimals) shows 29.555.670.000,00
View 5 Replies
View Related
Aug 27, 2014
I use the following code to delete from a table all records except those meeting the WHERE criteria:
Code:
DELETE tblABC.*, tblABC.SubjectID
FROM tblABC
WHERE (((tblABC.SubjectID)<>99 And (tblABC.SubjectID)<>432));
I'd like to run this exact same query, but on many other tables, all of which are stored in tblTablesToClean (TableID, TableName).
Any good way to have Access loop through the list of tables in tblTablesToClean, each time passing the name of the table into the DELETE code and running the code, until all tables have been processed?
View 5 Replies
View Related
May 21, 2014
I have an access 2007 database connect to sql server 2008.I am running a pass though query to search between two dates (this query has been fine for years)
If I now run any search using parameters from 26th March 2014 to date - the query takes 10+ minutes to run.If I then change the date to 25th March 2014 to date - it runs in a nano second.I have not changed the back tables and I have not changed the format the data is saved in.
View 2 Replies
View Related
Sep 5, 2013
I have wrote some code which calls a query using querydefs and then pulls all the records into a table. This table is then exported to excel, however I seem to be having some trouble with the export and am finding it difficult to identify where the problem is coming from. When I run my code in step by step, more of than not the code passes fine and exports to excel. However, most of the time when I run the code as a whole without step by step, then the excel application will load but the workbook will not. The application then continues to close and the code completes without error? The code for the opening of the excel file is below.
The pause is a function i created to see if it was a problem of giving the exel application some time to load!
Code:
Sub MiseEnForme1_Excel()
Dim AppExcel As Excel.Application
Dim WkbExcel As Excel.Workbook
Dim WksExcel As Excel.Worksheet
[code]....
View 12 Replies
View Related
Sep 11, 2005
Hi
I am struggling with what seems like should be a straightforward task. Unexpectedly however it has become an infuriatingly difficult one (no doubt due to my complete novice status).
I have a very basic d/base (3 tables) that I have been searching using basic SQL queries. I want to create a simple 'search' form that produces the results of my various queries without the need to work in SQL. Enter one or more search criteria, hit ENTER, results presented in datasheet perhaps?
Thought this would have been easy but I've had no luck. Can you please explain how I can pass a parameter from a form to a query?
Many thanks
Stuck21
View 1 Replies
View Related
Jan 29, 2008
I am trying to enter dates in a form that calls a report that invokes a query that uses the dates. It has been a less then satisfying experience. I am getting a Run-Time error 3122. Is it possible and I need to work on syntax or do I need to think of another way? BTW how do I lookup the Run-Time errors?
Thanks for helping an old guy learn new tricks.
Jim
View 5 Replies
View Related
Feb 15, 2007
I have a query set up. I need to pass a set of current records ( as I select them in a drop-down menu) in a form to the query as parameters. How would I do it with or without VB? Thanks !
EDIT: Forgot to mention that all combo boxes are bound so they are not customized dialog-boxes which are unbound
View 3 Replies
View Related
Jun 28, 2005
Hi there. What I'm attempting to do is pass multiple values from a multiple selection list box as criteria for an Append Query. Is there any way to do this? The DB keeps track of Real Estate boards and the forms that they use, I would like to be able to select all the boards in a given state/province, but have the ability to deselect some within that province if I don't need them in the query (this is the criteria i'm trying to pass). I don't need to use a list box, any control that would allow me to pass multiple values would be great. Anyone able to help? Thanks very much.
View 1 Replies
View Related
Aug 15, 2006
Is it possible to pass a variable to a form when a checkbox is clicked?
I have 8 tabs, each of which has a checkbox.
When a checkbox is clicked, I would like it to display 1 form but that form should display different data each time by either running a SQL query with specific variables passed to it or by running a different SQL query.
?
View 1 Replies
View Related
May 30, 2015
table name : Schedule
Field 1 = Vessel code
Field 2 = Voyage
Field 3 = ETA
Field 4 = berthed
Field 5 = Sailed
there is a query by using above table and data entry form based on that query.
need to add following facilitate
While data entering, if given voyage number is already exist for the particular vessel code, msg should be pop up immediately at that time saying " This voyage number is already exist"
How could this be manage ?
View 4 Replies
View Related
Dec 31, 2013
I have a query that selects records based on certain flags in each record. I can view the record in datasheet view, but I need to be able to edit the records selected by the query using another form. Is there any way to automate this process?
View 14 Replies
View Related
Jul 11, 2014
I am trying to print selected query how can I do that what is the command for that ...
View 1 Replies
View Related