Solved

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

Posted on 2013-01-20
7
388 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 500 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now