If Statement help please

dazstarr

Registered User.
Local time
Today, 17:07
Joined
Mar 19, 2007
Messages
132
Can someone help me with this problem please? I'm sure it is pretty simple but can't seem to figure it out.

I have a form with a subform on it. When users enter data onto the subform and presses back - the data is saved into a table. Here is the code behind the table:

----------------------------------------------------------------------
If Me.subInvoices!DateFrom <> Null Then

Me.subInvoices!Cost = subInvoices!CostCalc
Me.subInvoices!CostWithVariation = subInvoices!CostVarCalc
Me.subInvoices!VATAmount = subInvoices!VATCalc
Me.subInvoices!TotalCost = subInvoices!CostVAT
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close

Else

DoCmd.Close
-----------------------------------------------------------------------

The problem is that when a user enters some data on the form - the calculated fields don't save in to the table. A few other fields work fine (date and ID).

This works fine when the IF statement is removed. The reason I have added an IF statement is that if a user goes onto the form and presses back without entering data - it produces an empty record in my table due to the fact that I have calculated fields updating on exit.

Would I would like to do is the above code updates when the DateFrom field has been updated. If there is no data in this field - i would simply like it to close the form.

I know saving calculated field is not ideal but havent the time to change this. Please help!

Many thanks in advance
 
Hi, try this:
If Not IsNull(Me.subInvoices!DateFrom) Then

Regards
James
 
:cool:

Superstar!!!

Thank you so much!!

Works perfectly now!
 

Users who are viewing this thread

Back
Top Bottom