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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering a function

Status
Not open for further replies.

stacy0966

Programmer
Apr 27, 2004
35
US
Hello,

I have a form with the following fields:
Actually I have more but to make it simple I will look at three.

1. Month
2. Sales
3. JanSales

When Jan is entered in the month field I want JanSales to equal Sales. I know I can do this with an IF statement using one of the properties of the JanSales field or I could us an IIF statment in the control source. I would rather us a FUNCTION (at least I think this will work) but I'm not sure how to do it. Here is what I have tried.

Private JanSales() as Double
JanSales = Sales
end function

I put =JanSales() in the control source of the JanSales field but this field is displaying #Error. I can't figure out why. Any ideas would be greatly appreciated.

Thanks,

Stacy

 
Perhaps trying using an event. Under the month field, scroll down to After Update, and click on Code Builder, and there you can put your function.
 
Private Function JanSales() as Double

See [procedure | sub | function] &/or other similar of related topics under the ubiquitous {F1} (aka HELP).



MichaelRed


 
In the BeforeUpdate of the Month control:
On Error Resume Next
Me(Me![Month] & "Sales") = Me![Sales]
If Err <> 0 Then Cancel = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top