Code not working

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Code not working

Post by Leesha »

Hi,
I have a form with a date control. When a date is entered the code listed below is supposed a date on another form. IF there is no date, nothing should be changed. The code is not working and I'm not sure why. If I take out the "IF" statement and have the date just copy over there is not problem. It is only when I use a conditional statement.

If IsNull(Me.FPSubwayREopening) Then
'do nothing
ElseIf Not IsNull(Me.FPSubwayREopening) Then
Forms!sfrmStoreDemoCopyOver![NewStartDate] = Me.FPWMGoDate
Forms!sfrmStoreDemoCopyOver![Contract Expiration] = DateAdd("yyyy", 10, Me.FPWMGoDate)
End If

Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code not working

Post by HansV »

1) You check whether FPSubwayREopening is null, but you try to set the date on the other form to something else: FPWMGoDate. Is FPWMGoDate derived from FPSubwayREopening?

2) The prefix sfrm in sfrmStoreDemoCopyOver makes me suspect it's a subform. Is that correct? Subforms of a main form are not part of the Forms collection.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Code not working

Post by Leesha »

Hi Hans,
Thanks for the observation in #1!! That was the issue. I can't believe I missed that!
Leesha