• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

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

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
topUKlawyer
Asked:
topUKlawyer
1 Solution
 
mbizupCommented:
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
 
mbizupCommented:
Alternatively set the control source of the textbox to

= dateadd("y", 1, yourdatefield)
0
 
mbizupCommented:
Correction

= dateadd("yyyy",1,yourdatefield)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Dale FyeCommented:
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
 
topUKlawyerAuthor Commented:
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
 
Helen FeddemaCommented:
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
 
topUKlawyerAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now