Expression has no value error

T

Thanks, Chad

Hello, I have a form named frmcalendar with a subform named
frmReviewReminderSubForm and I want the subform to be visible= false if a
control named txtDateOfHire on my subform is null. The control is a date so
im getting an error "You entered an expression that has no value" here is the
on open event im using. Thanks!

If Me.frmReviewReminderSubForm.Form!txtDateOfHire = "" Then
Me.frmReviewReminderSubForm.Visible = True
Else
Me.frmReviewReminderSubForm.Visible = False
End If
 
K

Klatuu

You have two problems.

The error you are getting is caused by the strange but true fact that a
subform loads before the parent form. And, in any case, the Open event of a
form is too soon to reference any properties of the form. That is what the
Load event is for. Try moving your code to the load event.

But there is one other issue. "" does not evaluate to Null. If you are
testing for Null you have to use the IsNull function:

With Me.frmReviewReminderSubform
If IsNull(.Form!txtDateOfHire) Then
.Visible = True
Else
.Visible = False
End If
End With
 
T

Thanks, Chad

That worked great! I have one last question. If I have a query named
qryReviewReminder and it only shows records 30 befor to 30 days after a date
from a table. How could i create a record in a table if a date is 30 days
before a date from a table? I hope im explaining this good...Thanks!
 
K

Klatuu

Sorry, Chad, I don't quite understand. Can you provide some detail on what
you are wanting to do?
 
T

Thanks, Chad

Ok, I have a table tblTEST that has 5 fields, FirstName, LastName, Status,
Completed, DateOfHire. Now on my form frmReviewReminderSubForm it gets its
info from a query named qryReviewReminder and this query lets you know when
an employees review is coming up 30 days before to 30 days after. Anyway,
Here is what I wanted to do. When the frmReviewReminderSubForm is opened up
and there is a record that the query is showing then I want those records to
created in the tblTEST. How would I do this? Thanks!
 
K

Klatuu

Create an append query that uses the filtering criteria of your current query
that will run in the Load event of the subform. You will also want to add
criterai to the append query to prevent creating duplicate records being
added.
 
T

Thanks, Chad

Thank you for your help!

Klatuu said:
Create an append query that uses the filtering criteria of your current query
that will run in the Load event of the subform. You will also want to add
criterai to the append query to prevent creating duplicate records being
added.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top