Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

access display results of query in a form based on that query

Posted on 2013-01-20
7
Medium Priority
?
406 Views
Last Modified: 2013-01-20
I have a subform that i can put in a date.

the subform is based on a  query.

In the query i have created an expression which is "Date plus one year".

Can i display the results of the expression in the form via a text box and what would be the record source of the text box. I have tried dlookup without success
0
Comment
Question by:topUKlawyer
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38798389
If the subform is indeed bound to that query you should be able to set your textbox controlsource directly to

Date plus one year


It should appear in the dropdown of options for your control sources
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38798394
Alternatively set the control source of the textbox to

= dateadd("y", 1, yourdatefield)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38798403
Correction

= dateadd("yyyy",1,yourdatefield)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 49

Expert Comment

by:Dale Fye
ID: 38798405
If what you mean is that you want the query to reference the text box on you form, the query should look something like

Select * from your table where [YourdateField] = form!YourFormName.txtControlName

Since it is a date, you might needd to change that to

= cdate(forms!YourFormName.txtControlName)

And you will also need to add some code to the after update event of the date text box to force the form to requery.  That would look like

Private sub txt_date_afterupdate

    Me.requery

End sub
0
 

Author Comment

by:topUKlawyer
ID: 38798573
I need the text box to reflect the query field for the updated date )ie date plus one year

i dont understand Select * from your table where [your date field]

I have one table Vouchers

One date ie Date of voucher

I have a subform based on a query
The query has an expression Which is date add etc

I need to get that date into a textbox in the subform
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 38798739
Unless I am missing something, if you already have a calculated query field that yields the Date + 1 year you want, all you need to do is place a control bound to that calculated field on your form.  (Make it locked.)
0
 

Author Closing Comment

by:topUKlawyer
ID: 38798769
thanks, I have realised that the source for the form that was based on the query was not set to the query so the Date plus one year did not appear in the list under control source.

reset the form and pointed the text box to the query.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question