Get info from form (1 Viewer)

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
I have a query that I would like to get the dates from a form I have setup. The problem I am having is that there are formulas in the fields and I keep getting an error on the form when I try to run it.
 

Attachments

  • Acces Form.jpg
    Acces Form.jpg
    116.3 KB · Views: 40

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:25
Joined
May 21, 2018
Messages
8,529
A field parameter need to be fully defined
Forms!YourFormName!YourControlName
you only have a control name as far as I can tell so the query has no idea where that control is.
 

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
Yes, when I add [forms]![fadaseniors]![startdate] in the criteria field the form still errors.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:25
Joined
May 21, 2018
Messages
8,529
When you did that did the expression builder show startdate? Just checking to see you got the correct control name.
What is the error?
To make it a little easier you could put two calculated controls on your form and hide them.
txtMonth; = month([startdate])
txtYear: = iif(month([startDate]) > 7, year([startDate]) + 1, year([startDate]))
this way you can first check that you are getting the correct values
then reference txtmonth and txtyear in the query

Doing parameter queries and calculated ones are hard because you cannot debug easily. That could take a little out of it because you can verify at the form that the values are correct and make the query easier.
 

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
What if I took those two fields out and did a Between in the criteria referencing the startdate and the enddate on the form?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:25
Joined
May 21, 2018
Messages
8,529
I did not notice those fields are Group By and I think you want Where.
 

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
So I changed my Query and the form opens now but will not let me enter a date in the fields on the form.
Screenshot 2024-02-29 Access.png
Screenshot 2024-02-29 Access2.png
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:25
Joined
May 21, 2018
Messages
8,529
Do you have allow edits = no. If the form is read only but you want to enter into the unbound controls either lock the controls individually or make the query uneditable. The former is probably easier.
 

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
Ok so the form is letting me enter dates now but it is a continuous form and it is not loading the data. The query runs the data just fine.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:25
Joined
May 21, 2018
Messages
8,529
continuous form and it is not loading the data.
What does that mean? What is supposed to happen? Can you post the DB?
 

krc547

Member
Local time
Today, 01:25
Joined
Sep 1, 2023
Messages
38
Nevermind. I needed the form to Requery once they enter the dates so the query can grab the information. Thank you.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:25
Joined
Feb 19, 2002
Messages
43,275
Nevermind. I needed the form to Requery once they enter the dates so the query can grab the information. Thank you.
You are mis using the Requery to force Access to save the current record.
 

Users who are viewing this thread

Top Bottom