Refering to a query in the coding of a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to disallow the usage of a "project number" entered if the "Date
Worked" field in the same subform is >= to the "project end date" in the
project table.

I am an extreme beginner (under 1 year) but should be able to handle any
replies.

Please help.

Thank you in advance.
 
In your subform current event try:
If me.date_worked.value >= me.project_end_date then
me.project_number.enabled=false
'or me.project_number.locked=true (I prefer this)
End If

I'm assuming you can get project end date" in the project
table into your subform.
Good luck.
Geof.
 
That is the main problem I am having. Trying to get the
Projects.projectenddate into the subform. Any further suggestions ?

Thanks again
 
Does the underlying query of the subform and the Projects
table have common key fields that you can join on?
Geof.
 
In a nutshell. I used the Time & Attendance db sample and have altered to our
company's requirements. I have the Time Cards form and the Time Cards
subform. The project data entered in the Time Card form (or subform in the
case of entering project info) is linked to my Projects table. Therefore, I
can only grab a proj # in the project table. Perfect. I have added a
ProjectEndDate field to the Project table in hopes of being only able to
enter "Active" projects But at the same time, retaining data entered in the
past associated with that now "Inactive" project number.

Is there a way to make this all happen ? Any further suggestions would be
greatly appreciated.
 
If the project end date is in the main form, then from the
subform you can refer to it as:
Parent.Controls("project_end_date").Value
Does that help?
Geof.
 
The projectenddate is a new field I created in the project table. I don't
necessarily need to have the field added to the form or subform. But my
understanding was that it needs to be on the subfor so I can create a code
which will state something like the following statement:
(Fileds for data entry on subform= date worked, projectid, work id, hours,
rate, and a calculated total billing fiels)

During data entry, I wish to be able to enter a projectid. If the project id
entered has a project end date whhich is <= to date worked, I would like to
see have an error message stating the project id entered is inactive.
 
Put it either on the parent or child. Make the textbox
invisible. If you don't like that, then you'll have to get
it via some ADO or DAO recordset which is messier.
Geof.
 
Thenks.

That's part of my problem ... I don't know how to put it on either parent or
child.

Everything I have tried has either resutlred in no info or #NAME?
 
The project end date must be either in the query that is
the record source for your form or the query that is for
your subform. Once it is, in forms design view, click on
View, Field List and you should be able to drag and drop
it from the list onto your form.
Geof Wyght.
 
Back
Top