I have a report calculate total wages based on hours * hourly rate. The rate is kept in a table. I grab the rate using Dlookup. The same rate is used throughout all the calculations - only the hours change. So I figured it would be wise to assign the rate to a variable on form load to save on muliple Dlookup calculations (over 200).
Option Compare Database
'Declare the bill rate
Dim RespiteRate1 As Currency
Private Sub Report_Load()
'Assign values from Rate table
RespiteRate1 = DLookup("[Rate]", "[Rates]", "[RateCategory]= 'Respite'")
MsgBox RespiteRate1
End Sub
I added the message box just to see if it really is grabbing the rate and it is. I just can't seem to get it to print on the same report that loaded. I assign a value of =[RespiteRate1] to a text box on the form and I get nothing.
Probably is a scope problem, but I have played with various locations for the variable declaration.
I know this should be simple, but I guess not for me.
Option Compare Database
'Declare the bill rate
Dim RespiteRate1 As Currency
Private Sub Report_Load()
'Assign values from Rate table
RespiteRate1 = DLookup("[Rate]", "[Rates]", "[RateCategory]= 'Respite'")
MsgBox RespiteRate1
End Sub
I added the message box just to see if it really is grabbing the rate and it is. I just can't seem to get it to print on the same report that loaded. I assign a value of =[RespiteRate1] to a text box on the form and I get nothing.
Probably is a scope problem, but I have played with various locations for the variable declaration.
I know this should be simple, but I guess not for me.