Passing Parameters To A Form
Dec 22, 2006
Hi all,
I have a continuous form that is bound to a SQL Server view.
For each record in my form I have a button, which when pressed opens up a second form. The second form is bound to a stored procedure that takes a parameter. The parameter value that I want to pass to this second form is the value of one of the fields in the first form.
I did the following in the click event of the button on my first form:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "SecondForm"
stLinkCriteria = "[Field1]=" & "'" & Me![Field1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
However, when I run this it keeps prompting me to specify the value of Field1 so this value is obviously not getting through. Do you have any idea why this might be happening?
Thanks in advance
Kabir
View Replies
ADVERTISEMENT
Mar 23, 2006
Good Afternoon,
I am trying to create a form where a user will enter in a value into a text field. Afterwards, when the user clicks "Enter", a query will run and will LOOK FOR THE VALUE THAT WAS ENTERED INTO THE TEXT FIELD. i.e.
User enters their address into the field and clicks the enter button.
Afterwards, a query will run like
select * from customers where address = @address <== the value the user entered into the text field. This is where the mystery lies. How do you pass values?????
Thanks,
Nervous Jervous
View 6 Replies
View Related
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
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
Jun 15, 2005
Hi,
After years and years of working with Jet, I am now trying to use SQL Server backands and am having problems passing parameters to a stored procedure.
How can I build a query which where I can say "WHERE ([AField]=""" & Forms!BlarBlaretc.value & """)" as I can in access because as I understand it you can not look at front end information from the SQL backend.
Any help (and start at the beginning) would be much appreciated.
Cheers
Stu
View 1 Replies
View Related
Feb 1, 2006
Guys I need your help/Advice...
In my Access Database I have a query (lets say qry1) and in this query i have 2 fields for start and end date, which is provided by 2 Get functions.
also i have qry2 based on qry1
then qry3 based on qry2
and finally qry4(using sql in code) based on qry3, and non of these 3 queries have the start and end date fields.
now here is the problem: I am trying to set the criteria in qry4 and then open a record set on this query(qry4) to use the data that it pulls out...
strsql = ""
strsql = "SELECT Sum AS AREA_TOTAL " _
& "FROM qry3 " _
& "WHERE ENERGY_AREA like '" & Area & "';"
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset(strsql)
but when the last line is executed I get this error message:
Runtime Error '3061':
Too few parameters, expected 2.
i also tried doing this:
strsql = ""
strsql = "SELECT Sum AS AREA_TOTAL " _
& "FROM qry3 " _
& "WHERE ENERGY_AREA like '" & Area & "';"
Set MyDB = CurrentDb
MyDB.QueryDefs("qry4").sql = strsql
Set rst = MyDB.OpenRecordset("qry4")
but when the last line is executed it gives me an error message saying that the query does not exist or the name is not spelled correctly. (Ps. I have created the query and the criteria does update once the Select statement is run in the code!)
again the reason for this is that the query has not been populated as the main query (qry1) needs 'strat date' and 'end date'!
Is there anyway I can pass these 2 parameters to qry4 directly using code? If there is a way then this will definitly work as i tried opening the query manually in the Query window and after I input the 2 dates in the input box the query ran successfully!
I would appreciate any help/suggestion guys, I need to sort this out quickly as i have a deadline... Cheers
View 1 Replies
View Related
Dec 22, 2006
Hi,
I would like to transmit several parameters from my main form to the subform when I open it.
Parameters could be used in the subform by onload event, for eample, to define form caption, hide or show buttons, enable or disable edit boxes, give them a color, ... It could also allow to use the same form in different application contexts, which would reduce so the development time.
More than one technique might be possible.
I used the following one :
- I put the parameter value I want to pass into myParameter
- when click on the button to open the subform :
DoCmd.OpenForm myDocument, acNormal, , , , , myParameter
- when loading the subform, retreive the parameter value in Me.OpenArgs and using it (eg disable a button)
It works fine. But I can pass only a single value with this technique and it's not enough. I tried to give an array as myParameter and fill it with my parameters values, but Access refuses an array to be in the DoCmd statement for OpenArgs option.
Any idea about passing several parameters to the subform ?
Or may be an alternative to the DoCmd technique ?
Thanks.
View 5 Replies
View Related
Jun 4, 2007
Hey folks,
Not sure if this is the best forum but decided to put it here anyway.
I have a Access query that reads:
SELECT bleh
FROM blah
WHERE something > 10
Then in Excel I pull the data across using:
Set qdf = db.QueryDefs(qryName)
Set rs = qdf.OpenRecordset
and paste the data using
ws1.Range("IV1").End(xlToLeft).Offset(0, 2).CopyFromRecordset rs
I now want to change the query so the where statement reads
WHERE something > [amt]
So the question is how do I pass the value for the parameter value for [amt] from excel to access?
View 1 Replies
View Related
Feb 23, 2015
I have a query that sums up the number of parts used. This works fine.
I want to be able to limit this query to parts used after a specific date.
I have in my report
DoCmd.OpenReport "Part Totals Report", acViewPreview, , "[Part Date])>= " & SQLDate
The report is bound to a query that has 2 group by fields, 1 count field a a further field, a date field ([Part Date], that I put a default criteria on. This field is not displayed. If I don't put a criteria on this field disappears when I close and open again.
I pass a date to the program via a form and this ultimately ends up in SQLDate. When I run this I get promted to enter [Part Date] even though I'm setting it equal to SQLDate above. I can out garbage to a proper date in here either way the report picks up the default date entered in by the query.
1. Get rid of all of the parameters off the query.
2. Then you can use the Where Clause of the DoCmd.OpenReport code to specify the parameters based on your variables.
1.Not sure what this means but when I get rid of the criteria for the parameter the field disappears (I'm setting the show field to no as I don't want totals group by date). Getting rid of the field gives me all parts used.
2.I think I'm doing this in the above but will bow to superior knowledge!!
or is it I can't pass a parameter to a report run by a query that is grouping fields together to produce a count.
Incidentally once the report has been run (albeit with the wrong parameters) and I go into design mode and look at the property sheet for the report the correct filter is there (i.e., the date that has been input) but it quite clearly ignores this.
View 1 Replies
View Related
Aug 27, 2013
I have a query that searches for records that are between two dates using the WHERE clause. The two dates are referenced to two respective text boxes on a form. On the same form I have a button that will launch the query in VBA using querydefs. I get the error 3061 saying I need to input the parameters. Therefore I am a bit unsure how to set the parameters in VBA. So far I have done this:
Code:
Dim Db As DAO.Database
Set Db = CurrentDb
Dim QDef As DAO.QueryDef
Dim rst As DAO.Recordset
Set QDef = Db.QueryDefs("Rqt_F_BrokerageMandate_MF3_TEST")
[Code] ....
Where Date_VL is the field to be filtered. I know this is wrong but all examples I have seen have equated the parameter to a fixed value i.e 30/12/2012 for example, but I want this to be at the users discression. The only way I know of to get around this at the moment would be to write a temp query in VBA with PARAMETERS in the SQL code instead using the method above/
After this I'm going to assign the recordset to a matrix but that's a different story!
View 10 Replies
View Related
Oct 17, 2006
I am trying to pass parameters to my qury thru my combo selection. I keep getting this error "Data type mismatch criteria expression", does anyone have an idea why?
WHERE (((fShiftWorked([tblTimeLog].[timeStart])=[Forms]![frmOperatorWorkDone]![cboShift] Or IsNull([Forms]![frmOperatorWorkDone]![cboShift]))=True));
I have spent so much time onthis already and i am sick of it :mad:
Attached is my db. Please help me out here.
View 2 Replies
View Related
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
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
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
Feb 26, 2005
Hello,
I have a combo box on a main form and one on a subForm (DataSheet View)...
I want the value in the main_combo to populate the sub_combo for every record in the subform.
I think the code would look like this, but I cant get it to work?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub MAIN_DUNS_AfterUpdate(Cancel As Integer)
Me.CLIENT_DEAL.SUB_DUNS = Me.MAIN_DUNS.Value
End Sub
MAIN_DUNS= Combo on main form
SUB_DUNS= Combo on sub form
CLIENT_DEAL= Sub Form
DEAL_INFORMATION=Main Form
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any Ideas on how to get this to work correctly??
View 1 Replies
View Related
Mar 5, 2008
how can i pass a variable from one form to another
this works fine
Tracking_Number = Forms("Main").Control("mytext")
but if "mytext" was in vb (rather than from a text box as shown above) how can i do this
View 4 Replies
View Related
Jun 20, 2007
Hello,
I have made one form for report purpose. When I enter Start date and End date, I get report of the date range. What I am looking that I want to print the start date and end date in my report. How can I reference date text box in my report?
thanks
mithani
View 7 Replies
View Related
Feb 16, 2005
i have two forms. one is the main form and there i put button that opened another form.
when i open the second form i want to link the ID number from the main form to the second form so i wont have to insert the number each time i am opening it.
View 1 Replies
View Related
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
Aug 22, 2007
I am trying and have been unsuccessful at passing a value in a textbox from one form to another.
I have a form (Form1) and I click a button and Form2 opens.
What I want is a couple values from textboxes in the Form1 to populate a couple textboxes on Form2 when Form2 opens.
I CANT FIGURE THIS OUT....
PLease help
View 5 Replies
View Related
Jul 22, 2015
I have a form and in the subform for that I have a button that opens a pop up form. I want to pass the value [ACB ID] to an unbound text box in the popup form but I am having trouble. My code for the button in the subform is:
DoCmd.OpenForm "addPartNumberMod", acNormal, , "ACB = " & Me.[ACB ID], WindowMode:=acDialog
Currently when I press the button it asks me to enter the acb value instead of carrying it over. Also, when i do type in a number into the dialog, when the form opens, the text box is blank.
View 4 Replies
View Related
Feb 16, 2005
I've searched the forums for quite a while now and haven't exactly found the answer I'm looking for, so I appologize if it's already been covered elsewhere.
I have a tough situation to explain, but I'll do my best:
I have a query that has several fields that are calculated by adding or multiplying other fields in the same query - a few of which are parameters. I have made the parameters the "right way" by going to the query menu and selecting Parameters... and filling in the neccessary Parameters and Data Types instead of creating a new field in the query and putting my parameter info in that way.
So, long story short. I want to have a form where the user can enter in the parameters, select a value for a field from a drop down box, hit a "go" button and a report will be generated listing info from that query.
How do I go about entering parameters through a form and how do I put in a drop down box that will list all of the values available for a field in the query?
Thanks in advance,
Eric
View 5 Replies
View Related
Sep 11, 2006
I have created a form with multi-select list boxes, behind which is the following code to transform the users' selections into query parameters.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("Test")
If Me!lstAB.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstAB.ItemsSelected
strCriteria = strCriteria & "Centres.[Area Board] = " & Chr(34) _
& Me!lstAB.ItemData(varItem) & Chr(34) & "OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
Else
strCriteria = "Centres.[Area Board] Like '*'"
End If
strSQL = "SELECT * FROM Centres " & _
"Where " & strCriteria & ";"
qdf.SQL = strSQL
DoCmd.OpenQuery "Test"
Set db = Nothing
Set qdf = Nothing
End Sub
I would like to allow the user to set, on the same form, which field they want the resultant data to be sorted by, preferably by having a tick box alongside each list box, which sets that field as the sort field. The form will obviously need to allow only one of these tick boxes to be selected.
Can anyone advise me on how to modify the above code to make this possible?
Thanks,
Gary
View 1 Replies
View Related
Jan 9, 2008
Hi All,
Thanks to "Beginning Access97 VBA Programming" by R. Smith & D. Sussman, I was able to implement the use of a calendar form to allow a client to select a date, rather than keying one in. And here I thought I was done with the problem....Wrong !!! The calendar form only works if existing records already have a date(shortdate) associated with the record.
But when I try to create a new record, the date field is "null" and I can't figure out how to pass a date value to the calendar control even though it's receiving a null. I get this "type mismatch" error I've bumped into the part of the code that was supplied via the book where the "property set datecontrol (Byval ctldate as Control) is set, but I can't figure out
how to deal with this incoming "null" value from the newly created record.
Can anyone help? I'll check in later on tonight if anyone is needing part of the code as reference to what I'm trying to accomplish.
Thanks so much.......CementCarver
View 14 Replies
View Related
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
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