Subfrom Form Problem

G

Guest

Hi All,

Can some please tell me what i'm doing wrong here.

Private Sub Form_Open(Cancel As Integer)
If Form_Voucher_Subform!Expire_Date <= Date Then
Form_Voucher_Subform!Expired = True
End If
End Sub

I have a subfrom called "Voucher Subform" within a form called "repairers"

On the subform is two fields "Expire Date" and at checkbox "Expired".

I simply want the check box to be ticked (true) when the Expire Date is less
than or equal to Date() or Now().

I guess the code should fire OnCurrent instead of OnOpen really.

Any help would be appreciated.

Greg.
 
G

Guest

I don't think that syntax using underscore will work. A field name with a
space in it must be surrounded by square brackets [ ]

I believe it should be

Forms![Form Name]![Field Name]
 
G

Guest

Hi,
Subforms are buggars!
I play around with then a bit until I can get them to work too. I think your
syntax is wrong though, Not sure if you are changing Expire_Date in the
subform or whether it is there when you load the form but:

If you are changing the Expire_Date within the subform I would put something
like this on the On Change event.

If Me.Form_Voucher_Subform.Expire_Date <= Date Then
Me.Form_Voucher_Subform.Expired = 0
Else:
Me.Form_Voucher_Subform.Expired = 1
End if
Me!Form_Voucher_Subform.Form.Refresh

Or on the On Current when you open the form.

Not sure if its 100% correct but it should get you a bit closer.
 

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

Top