By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Simple Report Codes... for a newbee

P: n/a
All,
1. Do the following codes seem ok?
2. If so, then how do I pull the value of YOE1 and YOE2 into my
report? (to do some further calculations)

*************************************************
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)

Dim YOE1 As Double
Dim YOE2 As Double

While Me.Discipline("RN")
YOE2 = 1
If Me.YearOfEmp < 2 Then YOE1 = 1
Else: If Me.YearOfEmp >= 2 And Me.YearOfEmp < 5 Then YOE1
= 1.03
Else: If Me.YearOfEmp >= 5 And Me.YearOfEmp < 10 Then YOE1
= 1.0609
Else: If Me.YearOfEmp >= 10 And Me.YearOfEmp < 15 Then
YOE1 = 1.09
Else: If Me.YearOfEmp >= 15 Then YOE1 = 1.12
End If
Wend

While Me.Discipline(Not "RN")
YOE1 = 1
If Me.YearOfEmp < 2 Then YOE2 = 1
Else: If Me.YearOfEmp >= 2 And Me.YearOfEmp < 5 Then YOE2
= 1.05
Else: If Me.YearOfEmp >= 5 And Me.YearOfEmp < 10 Then YOE2
= 1.1025
Else: If Me.YearOfEmp >= 10 Then YOE2 = 1.16
End If
Wend

End Sub

*************************************************8
Thanks,
Perry
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
PerryC wrote:
All,
1. Do the following codes seem ok?
Yes and No. What are you doing with the While/Wend? It appears you are
calling a function called Discipline and passing the parameters of RN.
Not sure what the Not "RN" is. Maybe it should be
While Not Me.Discipline("RN")
instead.
2. If so, then how do I pull the value of YOE1 and YOE2 into my
report? (to do some further calculations)
I try to do this stuff in the query when possible. Again, I don't know
what you are while/wending. You could actually have a function you pass
in the query that returns back YOE1/2. Ex:

Yoe1 : GetVal1([YearOfEmp],[RNStatCode])
Yoe2 : GetVal1([YearOfEmp],[RNStatCode])

Public Function GetVal1(intYear As Integer, _
strRNCode As String) As DOuble

If strRNCode = "RN" Then
Select case intYear
Case 0 To 2
GetVal1 = 1
Case 0 To 2
GetVal1 = 1.03
Case 5 To 9
GetVal1 = 1.0609
Case 10 to 14
GetVal1 = 1.09
Case Else
GetVal1 = 1.12
End Select
Endif
End Function

Public Function GetVal2(intYear As Integer, _
strRNCode As String) As DOuble

If strRNCode <> "RN" Then
'put in correct GetVal2 values below
Select case intYear
Case 0 To 2
GetVal2 = 1.1
Case 0 To 2
GetVal2 = 1.2
Case 5 To 9
GetVal2 = 1.3
Case 10 to 14
GetVal2 = 1.4
Case Else
GetVal2 = 1.5
End Select
Endif
End Function

*************************************************
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)

Dim YOE1 As Double
Dim YOE2 As Double

While Me.Discipline("RN")
YOE2 = 1
If Me.YearOfEmp < 2 Then YOE1 = 1
Else: If Me.YearOfEmp >= 2 And Me.YearOfEmp < 5 Then YOE1
= 1.03
Else: If Me.YearOfEmp >= 5 And Me.YearOfEmp < 10 Then YOE1
= 1.0609
Else: If Me.YearOfEmp >= 10 And Me.YearOfEmp < 15 Then
YOE1 = 1.09
Else: If Me.YearOfEmp >= 15 Then YOE1 = 1.12
End If
Wend
While Me.Discipline(Not "RN")
YOE1 = 1
If Me.YearOfEmp < 2 Then YOE2 = 1
Else: If Me.YearOfEmp >= 2 And Me.YearOfEmp < 5 Then YOE2
= 1.05
Else: If Me.YearOfEmp >= 5 And Me.YearOfEmp < 10 Then YOE2
= 1.1025
Else: If Me.YearOfEmp >= 10 Then YOE2 = 1.16
End If
Wend

End Sub

*************************************************8
Thanks,
Perry


Nov 12 '05 #2

P: n/a
Thanks for your help... Here are some additional questions... since I am
really a newbee in this.

1. Where should I place the Yoe1: GetVal1([YearOfEmp],[RNStatCode])? In
the query of the Report? Where is[RNStatCode] defined? Is the
report's public function? should it say strRNCode instead?

2. The Public Function GetVal1.... As Double, is placed in the Report?

3. Is strRNCode the same as Me.Discipline? How does them equate?

P.S.: See my other post today... May not be there for another couple
hours

Sincerely,
Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

P: n/a
Perry Cheng wrote:
Thanks for your help... Here are some additional questions... since I am
really a newbee in this.

1. Where should I place the Yoe1: GetVal1([YearOfEmp],[RNStatCode])? In
the query of the Report?
Open up the current recordsource of the report. (Report property sheet,
data tab). You can paste the above
Yoe1: GetVal1([YearOfEmp],[RNStatCode])
in the query builder...modifying of course the reference to rnstatcode.
Where is[RNStatCode] defined?

I made it up. I figured you had some sort of code that determinies if a
record is RN or not.

Is the report's public function? should it say strRNCode instead?
No, I'd put the code in a code module. Database window, Modules.

I don't know your table or query structures. I'm simply providing an
example.

2. The Public Function GetVal1.... As Double, is placed in the Report?
Read above response.

3. Is strRNCode the same as Me.Discipline? How does them equate?
I guess so...I thought Discipline was a function you wrote that didn't work.

P.S.: See my other post today... May not be there for another couple
hours

Sincerely,
Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #4

P: n/a
Thanks for your help. I was able to get it to work in a simplier way
without using codes in the OnOpen Event. Thanks again.

Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.