Passing Form Data To An Sql Query

Nov 15, 2005

I have a hidden field on my form called "key". I can reffer to it as [forms]![MyForm]!key Is that right?

I also have a subform on this form that uses an sql query. I want this query to match on the key from above.

Shouldn't this work? select field1, field2 from table1 where keyvalue = [forms]![MyForm]!key

It doesn't. It returns a blank record.

Any help would be greatly appreciated.

View Replies


ADVERTISEMENT

Modules & VBA :: Passing Data From Query To Textbox On A Form

Jan 7, 2014

I have a form with a date field, when the user creates a new record, I would like the date field to automatically fill with the most up-to-date date from the Orderdate table.

Basically I need the code to do the following when a new record is created;

Search the Orderdate table for the most recent date and then auto fill the date field on the form with that date!!!!

My thinking so far...

Private Sub Command34 - where would you set this event on the properties i.e. Before update or On Got Focus ?

Docmd.OpenQuery "QryFindMaxDate"

I'm not really sure how to pass the date to the text box on the form,

End Sub

View 7 Replies View Related

Passing Data Onto Another Form

Apr 11, 2007

Hi,
i'm quite new to Access and I have a problem passing data from one form onto another.

I have a form that I use for quotations based on the table T Quotations on it I have:
QuotationID as my primary
RefCust referring to which customer
Date
and a few other fields

Now i'd like to add a button that when clicked will open my order form. In other words when a quote is confirmed I'd like to click on the quotation form to confirm it and create an order on the order form.
Order form will open with a orderID autogenerated BUT will return the same RefCust as on the Quotation form, the same date and will give the quotationID as Refquote onto the new form.

Ex: on form quotation I have
Cust: abc company
QuotationID: 123
Date: Feb 25 2007
Quote: $300

when i click on confirm

the Order form will open with:
OrderID: 002 (autogenerated)
RefQuoteID: 123
Date: Feb 25 2007 (even though today might be April 10)
RefQuote: $300

Please help me

View 1 Replies View Related

Modules & VBA :: Passing New Data From One Form To Another

Jan 19, 2015

I have a form called frmSchedule. Within this form, I have a combo box called cmbCD. I have code in the cmbCD NotInList Event. If the user inputs a number not in the list, the folowing code opens up a new form (frmPatients). The user can now add a new record to the database.

Code:
Private Sub cmbCD_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
Dim CR As String

CR = Chr$(13)

[Code] ....

I got this code and it works. However, when the user inputs a new number in frmSchedule, the NotInList event takes them to frmPatients. The users then have to re-type the number in frmPatients.

My question is: Is there a way I can trasfer the NewData from frmSchedule into frmPatients, so the users don't have to re-type the number?

View 2 Replies View Related

Forms :: Passing Data From A Form To A Table

Jul 5, 2013

I have a search form that searches for student ID from the student demographics table. I have it set when I click on the student ID (Frm_Student_Demographics_DailyCares) it will open the student visit form. When the student visit form opens it will show the student ID on the Student Visit Form but it is not being recorded in the student visit table.

I have Student ID control source on the Student Visit Form set as:

=[Forms]![frm_SearchStudent_DailyCares]![Frm_Student_Demographics_DailyCares].[Form].[SD_Record_ID].[Value]

My tables are called Student Demographics(parent table) and Student Daily Cares(child table) and they are linked by Student ID.

I have done this before on another part of this database but I just simply can't seem to find what I missed.

Here is a sample of my forms and tables.

View 2 Replies View Related

Passing Data From Child Form, To The Original Form

Dec 8, 2007

Hi All,

I'm not sure if this should go in here or in VB Programming, because it's to do with an Access Database but it's VBA code.
But I understand that VBA and VB are different in the way they work.

I think this may have been looked at before, but I'm not very good at using the search function. I've looked on google, but all I've seen doesn't seem to be for my use, so I came here as recommended by "RadioActive Frog" who I believe is a member here.


Right, basically, I am writing an Access database for my company's ordering system.

I have a form called "Enquiry" which has many tabs, one of these is the "client" tab in in here are many fields:

Firstname
Surname
Company
Addressline1
Addressline2
Town
County
Postcode
Phones
Fax
AltMobile
Email
ContactType

Now, there is an option to enter a new client or search the database for an existing client and it is basically the "new client" which I'm having issue with at the moment.

Basically, clicking the button "New Client" opens another form called "Client". Here, the user enters the data into fields which are the same as above (but on this contact form).

When done, they click a button called "Save and Close" which then asks the user if they want to paste their entered data into the original main "Enquiry" form.

It's this last bit, the transferring of this data I can't get my head around and would be incredibly greatful for help with.

My Code is below:

Code:Private Sub Save_Click()On Error GoTo Err_Save_Click ' On clicking save, a dialogue box will open asking if you want to paste this data ' into the enquiry form. Clicking yes will do this. Clicking no will just close the box 'declare intpress as an integer Dim SavePress As Integer 'Save Command DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 'when save and paste is clicked, ask if the information should be pasted into the form or not SavePress = MsgBox("Would you like to paste this Contact Information into the Enquiry Form?", vbQuestion + vbYesNo, "Paste details") If SavePress = 6 Then 'If the enquiry form was the form which initiated the cotact form, then copy and paste 'the informtion into the enquiry form and the close the form 'If "Enquiry" = Me.OpenArgs Then <------ I have decided not to use this, as it doesn't seem to work. (I'm probably not using it correctly) Enquiry!FIRSTNAME = Me.FIRSTNAME Enquiry!SURNAME = Me.SURNAME Enquiry!COMPANY = Me.COMPANY Enquiry!CATEGORY = Me.CATEGORY Enquiry!ADDRESSLINE1 = Me.ADDRESSLINE1 Enquiry!ADDRESSLINE2 = Me.ADDRESSLINE2 Enquiry!TOWN = Me.TOWN Enquiry!COUNTY = Me.COUNTY Enquiry!POSTCODE = Me.POSTCODE Enquiry!PHONES = Me.PHONES Enquiry!ALTMOBILE = Me.ALTMOBILE Enquiry!EMAIL = Me.EMAIL DoCmd.Close acForm, "Contact" Else DoCmd.Close acForm, "Contact" End If Exit_Save_Click: Exit Sub

But It's not working. It's giving an error saying "Compile Error: Variable not defined" and it highlights the word which I've mad RED in the code above. Now, I tried changing the exclamation for a fullstop, and I also tried writing "Form.Enquiry.FIRSTNAME" (and also with exclamation marks). None have given a working result.


I'll try and get some print screens too for more visibleness (new made-up word there) so you can see what I mean.


Blessings,
Si


Edit: here are a couple of print screens:

1. The Client tab/page of the main enquiry form:

http://i6.photobucket.com/albums/y218/Mr_Si/Enquiry.jpg


2. The Client Details form, which opens as a result of pressing the "New Client" button in the main enquiry form (shown in the background):

http://i6.photobucket.com/albums/y218/Mr_Si/Client.jpg


Argh! I forgot I couldn't post links to URLs

View 1 Replies View Related

Forms :: Passing Text Box Data To A Function Via A Query

Jan 28, 2014

I have a function in a module that looks like this (it takes 2 dates as arguments):

Code:
Function get_KPIScanAgeRange(in_ScanDate As Date, KPIDate As Date) As String
Dim ret As String
ret = "Invalid"
' return value, by default is because age is negative number

[Code] .....

I'm trying to pass the date in a text box which exists in a form called "d3FormAging". The text box name is "KPIDate". The query looks like this:

Code:
SELECT Query_d3_Open.[Company No], get_KPIScanAgeRange([Scan date],[Forms]![d3FormAging]![KPIDate]) AS KPIScanAgeRange, Count(Query_d3_Open.[Scan date]) AS Scans
FROM Query_d3_Open
GROUP BY Query_d3_Open.[Company No], get_KPIScanAgeRange([Scan date],[Forms]![d3FormAging]![KPIDate])
ORDER BY Query_d3_Open.[Company No], get_KPIScanAgeRange([Scan date],[Forms]![d3FormAging]![KPIDate]);

For some reason Access doesn't recognize the "[Forms]![d3FormAging]![KPIDate]" when I pass it to the function. I get run-time error 3070 with information that Access can't recognize this expression even though the code should be correct as it's made with the expression builder and I'm sure the form that contains the text box is open when the query runs.

View 2 Replies View Related

Modules & VBA :: Passing Parameter To A Query - Data Sent To A Table

Jun 5, 2013

I have a function that when called transfers a query recordset to an excel spreadsheet then emails it. At the end of the function I use code to write the date sent to a table. Each time the function is called I only need records in the query that have been modified since the last time the function was called. I have a field in the query 'LastModified' with a criteria '>[Enter Date]'. I then look up the date in the table and enter it manually. I know how to look up the last date sent in table using code but getting the >#SomeDate# in the query with VBA.

Code:
DoCmd.TransferSpreadsheet acExport, , "qryUpdateWebmaster", _
"C:SubmarinersUpdates_Sent" & fname & ".xlsx", True, "Webmaster_Update"

View 1 Replies View Related

Forms :: Stock Inventory - Opening Form And Passing Data

Jan 9, 2014

I have a form that displays a stock inventory, one of the fields I use is called [ItemCode].

On the Stock_Inventory form I have 10 command buttons that open other forms to display additional product information.

These were previously sub_forms that sat in a tabbed control box within the Stock_Inventory Form but as it now takes a while for the form to load (lots of queries running each time you search for a product) users are getting slightly frustrated.

So, what I decided to do, was move each subform from the tabbed control into a new form and open that form when it is needed by the user.

OK, when I open Stock_Inventory and search for a product [ItemCode = "ABC123"] and then want to see the Sales_History, I have to open my new form, Stock_Inventory_Sales_History, within this form are two sub-forms, each subform has a field called [ItemCode].

However, when Stock_Inventory_Sales_History opens it asks me to input the parameter [ItemCode] twice, I presume this is because the Stock_Inventory_Sales_History does not have a record source and that the subforms need [ItemCode="ABC123"] to run each query and return the data.

I need to pass the [ItemCode] from the Stock_Inventory form to each of the 2 Subforms that are on the Stock_Inventory_Sales_History form automatically.

View 4 Replies View Related

Passing Parameter From Form Into Query?

Sep 3, 2007

I know this is probably a basic question- but Im not finding a clear answer here.

Basically- I have a value that I want to select from a drop down box on a form (not created yet). That value will get inserted into my query for a calculation I am doing. The form will pop up the results of the query in a table/dataset.

How do I designate the variable in the query that is being inserted from the form? I am using Access 2002- is there a way to visually perform this task (ie- drag/drop type thing)?
Thanks guys!

View 6 Replies View Related

Passing Form Value To Append Query

Nov 13, 2007

Dear All, I have a problem which I need to solve and am in need of a clue!

I have a table which contains lots of line items relating to quotes. Each quote usually contains three line items and is prefixed in all cases with a number which relates to number of users. For example

5 5 User Software Details Price Cost Note

in the table there are up to 100 users and each has line 3 items. I automate quote generation by using a form. In the form a quote reference is generated and a text box for the number of users. I have a command button which then, based on the value of users text box, selects from the line items table and sends the records to my TblQuotes.

My Tbl quotes is exactly the same structure as my line items table except it also has a field for the quote reference which is in the form.

Where I am stuck is I cant seem to get Access to send the quote reference into the TblQuotes as part of the append query.

Please help! :confused:

View 9 Replies View Related

Passing Values From Form To Query?

May 2, 2013

I have a form - RunQuery And I have a query - Q2.

The form has text boxes for dates txtStart2, txtEnd2.

On button click I have a macro.

Query Name Q2

view Datasheet
datamode edit

The query will open

The query has a field Assigned which is Date/Time

In my query design view I have this as the criteria:

>[Forms]![RunQuery]![txtStart2] Or <[Forms]![RunQuery]![txtEnd2]

I also have filter on load set to yes.

However the filter does not seem to work.what is missing or wrong?

View 6 Replies View Related

Passing Values On Form To Union Query

Oct 20, 2005

I'm currently working on a database which provides copier and postage activity in my department, using Access. I'm trying to debug a query which is called by a form that accepts input for a particular month and year. Whenever the OK button is clicked, it gives a message "The Microsoft Jet database engine does not recognize 'Combination Query' as a valid field name or expression."

"Combination Query" is a union query which calls two intermediate queries, each of which in turn calls a base query. Only one, the query responsible for gathering copier activity, is a crosstab query.

The problem I believe lies in either or both of the base queries only when the form is used. When I use a regular parameter query, I receive no error messages.

Here is the SQL code I used for each:

Query 1: Copier Activity
Code:PARAMETERS [Forms]![frmObtainMonthlyInfo]![cmbMonth] Long, [Forms]![frmObtainMonthlyInfo]![cmbYear] Long;TRANSFORM Sum([big table].Copies) AS SumOfCopiesSELECT [big table].[Copy Code], [User codes].Alias, Sum([big table].Copies) AS [Total Of Copies]FROM [User codes] INNER JOIN [big table] ON [User codes].[Copy Code] = [big table].[Copy Code]WHERE (((DatePart("m",[big table].[Time]))=[Forms]![frmObtainMonthlyInfo]![cmbMonth]) AND ((DatePart("yyyy",[big table].[Time]))=[Forms]![frmObtainMonthlyInfo]![cmbYear]))GROUP BY [big table].[Copy Code], [User codes].AliasPIVOT [big table].[Copier Location];

Query 2: Postage Activity
Code:PARAMETERS [Forms]![frmObtainMonthlyInfo]![cmbMonth] Long, [Forms]![frmObtainMonthlyInfo]![cmbYear] Long;SELECT [big Postage Activity].sAcctNum AS Account, Sum(Nz(cBaseRate*lNumPieces,0)+Nz((cRegisteredFee+ cCertifiedFee+cReturnRecFee+cReturnRecMerchFee+cSp ecDeliveryFee+cSpecHandlingFee+cRestrictedDelvFee+ cCallTagFee+cPODFee+cHazMatFee+cSatDeliveryFee+cAO DFee+cCourierPickupFee+cOversizeFee+cShipNotificat ionFee+cDelvConfirmFee+cSignatureConfirmFee+cPALFe e+cResidualShapeSurcharge)*lNumPieces,0)) AS TotalFROM [big Postage Activity]WHERE (((DatePart("m",[big Postage Activity].[sSysDate]))=[Forms]![frmObtainMonthlyInfo]![cmbMonth]) AND ((DatePart("yyyy",[big Postage Activity].[sSysDate]))=[Forms]![frmObtainMonthlyInfo]![cmbYear]))GROUP BY [big Postage Activity].sAcctNum;

I edited this to make it look similar to a recommendation posted on another forum, but sometimes I would get the message "The Microsoft Jet database engine does not recognize '[Forms]![frmObtainMonthlyInfo]![cmbMonth]' as a valid field name or expression."

I also included PARAMETERS [Forms]![frmObtainMonthlyInfo]![cmbMonth] Long, [Forms]![frmObtainMonthlyInfo]![cmbYear] Long; as the first line in the intermediate tables, but I still receive the same error message.

I'm wondering if there was something I overlooked or if there was a way around this. I can post the other queries if you need those. Many thanks in advance for your help.

View 3 Replies View Related

Passing Parameters To A Query From A Form To Filter A Report

Aug 15, 2006

I would like to have a user enter a start date and an end date into two
textboxes on a form. The two dates will be used to query a table. I
would then like to print a report that was created from that query.

Here is the query created as a stored procedure:


SELECT Transactions.*, Hoods.*
FROM Hoods INNER JOIN Transactions ON
[Hoods].[ID]=[Transactions].[BoxID]
WHERE ([Transactions].[Date] Between [@StartDate] And [@EndDate])
ORDER BY [Transactions].[Date];


What would be the best way to pass txtStartDate to @StartDate and
txtEndDate to @EndDate in the VBA code of the form? How would I open or
print the report created from that query filtered on that date range?


Any suggestions? Am I going about it wrong? Should I have created the
report from the above query, or should I do it another way? Can anyone
direct me to some code that does all of the above or something
similiar?


Thanks.

View 14 Replies View Related

Queries :: Passing Results From A Form Into Query Errors

Nov 14, 2013

I am working on a database that contains patient demographic information. I have a form that prompts the user to enter either the medical record number or part of the patient name. Once you click search it'll then display a 2nd form with a list box outputting the results. Then from there the user can click on one of the entries in the listbox and it'll display the full demographic information on a 3rd form.

Now my problem is on the search part, it completely ignores if I have a medical record number entered. It continues to search by name only.

In my query for med rec # I have

[Forms]![frmSearch]![txtHistn]

where txtHistn is the text box field passing into the query. And for patient name column in the query under OR I have the following:

Like "*" & [forms]![frmSearch]![txtPname] & "*"

So I am confused why it ignores the medical record number entirely.

I have a test database attached. This is just a sample with dummy data entered and not designed pretty. Through this up for another issue I had yesterday that has been resolved but now discovered this query one. The frmSearch is how it begins. If you search by Smith it'll bring up the two Smiths I have entered. If I leave the field blank and enter 1 for the medical record number it treats it as null and displays everything. How can I fix this?

And while on the topic of query, the true database I am working with resides on an Power I series (formerly AS400s) and only linking to their tables. The data is entered in all Caps in the tables. How can I force whatever the user enters into the search screen that it will automatically uppercase the letters before performing the search? Without having the user to remember to enter with their cap locks on.

View 14 Replies View Related

Reports :: Navigation Form - Passing Query Parameters To A Report

Aug 4, 2014

I have a navigation form that will have 6-8 tabs. We were using about that many databases, but we are finally consolidating them into one. The result of us using so many databases has been the multitude of forms and reports that were necessary for each database prior to merging them together.

The problem: There will be anywhere from 12-20 (text boxes) that the user can use to search anything in our database. What we need to have happen, if possible, is for those search parameters to show up in the header of our report if they have text in them. If the text box is blank, it should not show up in the header of the report.

I have read how to to do the start/end date technique, but I do not know if that would work for what we are doing since the boxes would only show up if they are populated by the user.

View 4 Replies View Related

Forms :: Passing A Value From A Query To A Form - Eliminate Negative Sign

Mar 13, 2014

I get a negative value when i run the below expression.

The expression picks the month from the field txtmonth in form "frmYearToMonth" and search's the crosstab query "ctbYearToMonth" for the corresponding value in txtMonth.

=DLookUp([Forms]![frmYearToMonth]![txtMonth].[Value],"ctbYearToMonth","")

The value is correct but there is a negative sign before the value how do i eliminate the negative sign.

View 5 Replies View Related

Passing Data Between Tables

Feb 8, 2008

I have a bit of a dilemma in my related tables (screen shot of relationships attached).

Basically at the moment I am using a 1-1 relationship between my tables using the primary key of CYID. The CYID is populated using an auto number at the moment but the problem I have is if the tables become out of sync with the numbering.

What I would like to do is when I create a new record in tblClientDetails is create a new record in each corresponding table that is linked and then pass the CYID across to each table. Can anyone offer any assistance or give me any suggestions for better ways of doing this?

View 2 Replies View Related

Passing Data Through Forms

Feb 24, 2006

I know there are other threads on this but I have tried all the solutions and none have worked.

I currently have 2 forms, a customer form and a customer health form.

I want to pass the membershipNo from the customer form to a newly opened customer health form.

this is the code I am using but it isnt working, actually it is, but when i delete all the current customer entries and enter new ones it doesnt pick up the details and all the controls on the customer health form are greyed out.

Private Sub cmdCustHealth_Click()

DoCmd.OpenForm "CustomerHealth", , , "[MembershipNo] = " & Forms!CustomerForm!membershipNo, , acDialog

End Sub

The control source on the text box on the customer health form is "membershipNo" where am I Going wrong?

View 1 Replies View Related

Passing Data Via DDE To Access

Mar 21, 2007

I'm trying to pass data from a macro using DDE to Access (it must use DDE), however, I can't seem to get the data to a Module, Macro or Form (either one will do).

Is there a way to pass arguments to any of these three? I'd imagine the easiest would be to run a macro like DDEExecute channel1, "[RunMacro MyMacro]" but how can I pass the data specifically do the Macro?

View 5 Replies View Related

Passing Parameter From A Data Access Page.

Jul 28, 2005

Hi - I am looking for some help understanding the instructions in the msdn article on how to pass a parameter from a DAP. Please refer to the article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k2/html/odc_PassParam.asp


I was able to follow the instructions until Page 2 of this article...where it says: "Add the functions to write, read and delete cookies in a separate global script block."

I do not understand how to create a global Script block. Do I just copy and paste this code right below the 1st code on Page 2? Or, is there a way to create a global script block separately and add this code there?

I am unable to find that much Online resources on DAP as other Access topics. I thought posting my question here would be the last resort for assistance! :confused:

View 3 Replies View Related

Date Format When Passing Data To An Email

Aug 31, 2005

I have a button on a form that creates an email and inserts fields from my database. I have a field that is set to Long Date format type, but when it populates the email, it shows as a Short Date format type. Is there anyway to retain the Long Date format?

View 1 Replies View Related

Data Succession-passing Db Tables To New Operators

Feb 23, 2006

I am preparing a database application that will be used by one person in an organization. Frequently , (every year or two) the program will be given to another (usually a laptop) user in the organization as that person assumes the task of the program’s operation and responsibilities.

I would like the user to load the program from the installation CD (made with Wise Installation System and SageKey softwares) on each computer each time there is a brand new user and each time a subsequent user takes over. However, each successive user needs to have the data files passed from the last user.

At face value it seems that having a front end/back end arrangement might be the most desirable. Can anyone jump start me on the best way to accomplish this process to EZ data transfer?

Thanks in advance to all,

JQ

View 1 Replies View Related

Reports :: Passing Data To Report From A ListBox

Mar 14, 2013

How can I pass data (an employee's first and last name) to a report ? I captured the employee's name from the listbox, but can't seem to pass it to the report. The desired report will only have the employee's name and records for related fields on the report. The table (contains emloyees' history data), form name, listBox (contains employees' names), and variable (contains the employee's name) are listed below.

Table_Employee_Detail_History
Form_Employee's Reports
Report_Attendance_Report
stremployee (variable

View 14 Replies View Related

Modules & VBA :: Passing Values Of Selected Items From First Form Until Third Form

Aug 12, 2013

I would like passing values from first form until third form.

In the first form I have a list box after selecting items (For each selected item in first form I have 4 values) and pressing button (or right click of mouse) the second form will be open, then in the second form I have 2 option (inserting, deleting), when I select inserting or deleting in the second form, third form will be open, in the third form there is a "OK" button, when I press that, passed values from first form will be used for inserting or deleting records to the table.

View 4 Replies View Related

Forms :: Passing Values From One Form To A New Record In Another Form

Oct 25, 2013

Have one form that contains values AssociatedProject and AssociatedRelease that need to be passed onto another form that opens with a new record. Have tried different variations based on what I read here and couldn't get them to work.

Initial form - frm_ViewList contains the values that I need to pass on and has a "Add" button to bring up the new form that also creates a new record. The add button contains the following:

Dim stDocName As String
MyAssociatedProject = Me.AssociatedProject
MyAssociatedRelease = Me.AssociatedRelease
stDocName = "Frm:ManageQuestionsAnswersProc"
DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec

Then in the second form Frm:ManageQuestionsAnswersProc the following code is contained in the Before Insert:

Me.AssociatedProject = MyAssociatedProject
Me.AssociatedRelease = MyAssociatedRelease

View 3 Replies View Related







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