IF Staetement Question

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Hi

I want an image to be visible if the event is fully booked I an unbound
control on the page that calculates the number of spaces called [number of
spaces] it calculates it using;

=[AvailableSpaces]-IIf([Events
Subform].[Form].[RecordsetClone].[RecordCount]=0,0,[Events
Subform].[Form]![Total Attendees])

This works and has for years, to make the image visible I put the following
code:
into the Form on current event:

If Nz(Me.[Spaces Remaining]) = 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If

The image is always visible on every record, now I may have made a mistake
on the code because I normally do, but I have also noticed that when a record
loads the control [Spaces Remaining] has a value briefly before becoming 0
like its doing the calculation on the after the form is loaded

Can anyone help

thanks

Phil
 
You might try redoing the calculation in the VBA and also checking for values
that are less than 1.

Dim LCount as Long

LCount = Nz([AvailableSpaces],0)-
IIf([Events Subform].[Form].[RecordsetClone].[RecordCount]=0,0
,[Events Subform].[Form]![Total Attendees])

Debug.Print LCount 'Temp line to check results

If LCount <= 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Hi Maurice

thanks for your reply, unfortunately it makes no diffrenece to the end
result it still does not work

Thanks

Phil


Maurice said:
Hi Phil,

Shouldn't this read:

If Nz(Me.[Spaces Remaining],0 ) = 0 Then

etc...

--
Maurice Ausum


Phil said:
Hi

I want an image to be visible if the event is fully booked I an unbound
control on the page that calculates the number of spaces called [number of
spaces] it calculates it using;

=[AvailableSpaces]-IIf([Events
Subform].[Form].[RecordsetClone].[RecordCount]=0,0,[Events
Subform].[Form]![Total Attendees])

This works and has for years, to make the image visible I put the following
code:
into the Form on current event:

If Nz(Me.[Spaces Remaining]) = 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If

The image is always visible on every record, now I may have made a mistake
on the code because I normally do, but I have also noticed that when a record
loads the control [Spaces Remaining] has a value briefly before becoming 0
like its doing the calculation on the after the form is loaded

Can anyone help

thanks

Phil
 
Hi John

Thank you for your reply, I have tried your code but get a compile error
whenever I load the form it says cant find field reffered to in form, I have
checked names but all seem ok, with VBA unless the mistakes are obvious I
often miss then I have reposted what I have put in form on current event, is
it because the subform has not loaded yet so cannot get recordset? I am
really stuck here

Thanks for your time

Dim LCount As Long

LCount = Nz([AvailableSpaces], 0) - IIf(Me.[Events].[Events
Subform].[Form].[RecordsetClone].[RecordCount] = 0, 0, [Events
Subform].[Form]![Total Attendees])

Debug.Print LCount 'Temp line to check results

If LCount <= 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If


Phil

John Spencer said:
You might try redoing the calculation in the VBA and also checking for values
that are less than 1.

Dim LCount as Long

LCount = Nz([AvailableSpaces],0)-
IIf([Events Subform].[Form].[RecordsetClone].[RecordCount]=0,0
,[Events Subform].[Form]![Total Attendees])

Debug.Print LCount 'Temp line to check results

If LCount <= 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi

I want an image to be visible if the event is fully booked I an unbound
control on the page that calculates the number of spaces called [number of
spaces] it calculates it using;

=[AvailableSpaces]-IIf([Events
Subform].[Form].[RecordsetClone].[RecordCount]=0,0,[Events
Subform].[Form]![Total Attendees])

This works and has for years, to make the image visible I put the following
code:
into the Form on current event:

If Nz(Me.[Spaces Remaining]) = 0 Then
Me.Image235.Visible = False
Else
Me.Image235.Visible = True
End If

The image is always visible on every record, now I may have made a mistake
on the code because I normally do, but I have also noticed that when a record
loads the control [Spaces Remaining] has a value briefly before becoming 0
like its doing the calculation on the after the form is loaded

Can anyone help

thanks

Phil
 
Back
Top