Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement problem

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB
Can anyone help

I can't see what I'm doing wrong here but I keep getting a compile error saying Else without if

Private Sub DateIssued_AfterUpdate()

If IsNull(Me.DateIssued) Then Forms!frmPassReissue.AvailableToIssue.Value = "-1"

Else: Forms!frmPassReissue.AvailableToIssue.Value = "0"
End If

End Sub
 
You seem to be mixing two different formats.

Code:
Private Sub DateIssued_AfterUpdate()

If IsNull(Me.DateIssued) Then
    Forms!frmPassReissue.AvailableToIssue.Value = "-1"
Else
    Forms!frmPassReissue.AvailableToIssue.Value = "0"
End If

End Sub

 
... Or much better:


[tt]Forms!frmPassReissue.AvailableToIssue=IsNull(Me.DateIssued)[/tt]

I very much doubt that you mean text ("-1","0") for true and false (-1,0)

 
sorry I'm confused.

What I'm trying to do is change the checkbox 'AvailableToIssue' so that if I have added a date to the dateissued field the checkbox becomes clear and if I remove a date from the dateissued field the 'AvailableToIssue' checkbox is checked.

the AvailableToIssue box is on a different form
 
This line:

[tt]Forms!frmPassReissue.AvailableToIssue=IsNull(Me.DateIssued)[/tt]

Should do that.

[tt]IsNull(Me.DateIssued)[/tt]

Evaluates to True if no date has been filled in, so you get:

[tt]Forms!frmPassReissue.AvailableToIssue=True[/tt]

You will need to use a suitable event(s), the Current event for the form with DateIssued, and the After Update event for DateIssued.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top