Hello, I am trying to create a reciept database to log all my receipts and to let me know how much I spent for the month I have the query's set up just fine but as we all should know the months that have not come yet access is giving me a error when I go to run the vba script because the queries are not picking up anything. Let me post my vba code but before I do I have queries set for each month labeled qryJanTotal to qryDecTotal to give a count on for each transaction and the Total amount spent. Here is the code
Private Sub Form_Load()
Dim strMonth1 As Double
Dim strMonth2 As Double
Dim strMonth3 As Double
Dim strMonth4 As Double
Dim strMonth5 As Double
Dim strMonth6 As Double
Dim strMonth7 As Double
Dim strMonth8 As Double
Dim strMonth9 As Double
Dim strMonth10 As Double
Dim strMonth11 As Double
Dim strMonth12 As Double
strMonth1 = DLookup("SumOfAmount", "qryJanTotal")
Me.txtJanuary = strMonth1
strMonth2 = DLookup("SumOfAmount", "qryFebTotal")
Me.txtFebruary = strMonth2
strMonth3 = DLookup("SumOfAmount", "qryMarTotal")
Me.txtMarch = strMonth3
strMonth4 = DLookup("SumOfAmount", "qryAprTotal")
Me.txtApril = strMonth4
' strMonth5 = DLookup("SumOfAmount", "qryMayTotal")
' If strMonth5 = Null Then
' Me.txtMay = 0
' Else
' Me.txtMay = strMonth5
' End If
' strMonth6 = DLookup("SumOfAmount", "qryJunTotal")
'Me.txtJune = strMonth6
' strMonth7 = DLookup("SumOfAmount", "qryJulTotal")
' Me.txtJuly = strMonth7
' strMonth8 = DLookup("SumOfAmount", "qryAugTotal")
' Me.txtAugust = strMonth8
' strMonth9 = DLookup("SumOfAmount", "qrySeptTotal")
' Me.txtSeptember = strMonth9
' strMonth10 = DLookup("SumOfAmount", "qryOctTotal")
' Me.txtOctober = strMonth10
' strMonth11 = DLookup("SumOfAmount", "qryNovTotal")
' Me.txtNovember = strMonth11
' strMonth12 = DLookup("SumOfAmount", "qryDecTotal")
' Me.txtDecember = strMonth12
End Sub
I have not entered the Month of April receipts yet just to see if it is my code that is wrong or the way it was recieving the data. As you can see I commented much of it out to try and trouble shoot the code. I also tried to right an if statement to see if I can put parameters on the code but now I am at a loss I realize I could of used an array on this but I am still a little shaky on using them. On the If statement I tried to use Null to see if I can give it perameters but no luck.
Private Sub Form_Load()
Dim strMonth1 As Double
Dim strMonth2 As Double
Dim strMonth3 As Double
Dim strMonth4 As Double
Dim strMonth5 As Double
Dim strMonth6 As Double
Dim strMonth7 As Double
Dim strMonth8 As Double
Dim strMonth9 As Double
Dim strMonth10 As Double
Dim strMonth11 As Double
Dim strMonth12 As Double
strMonth1 = DLookup("SumOfAmount", "qryJanTotal")
Me.txtJanuary = strMonth1
strMonth2 = DLookup("SumOfAmount", "qryFebTotal")
Me.txtFebruary = strMonth2
strMonth3 = DLookup("SumOfAmount", "qryMarTotal")
Me.txtMarch = strMonth3
strMonth4 = DLookup("SumOfAmount", "qryAprTotal")
Me.txtApril = strMonth4
' strMonth5 = DLookup("SumOfAmount", "qryMayTotal")
' If strMonth5 = Null Then
' Me.txtMay = 0
' Else
' Me.txtMay = strMonth5
' End If
' strMonth6 = DLookup("SumOfAmount", "qryJunTotal")
'Me.txtJune = strMonth6
' strMonth7 = DLookup("SumOfAmount", "qryJulTotal")
' Me.txtJuly = strMonth7
' strMonth8 = DLookup("SumOfAmount", "qryAugTotal")
' Me.txtAugust = strMonth8
' strMonth9 = DLookup("SumOfAmount", "qrySeptTotal")
' Me.txtSeptember = strMonth9
' strMonth10 = DLookup("SumOfAmount", "qryOctTotal")
' Me.txtOctober = strMonth10
' strMonth11 = DLookup("SumOfAmount", "qryNovTotal")
' Me.txtNovember = strMonth11
' strMonth12 = DLookup("SumOfAmount", "qryDecTotal")
' Me.txtDecember = strMonth12
End Sub
I have not entered the Month of April receipts yet just to see if it is my code that is wrong or the way it was recieving the data. As you can see I commented much of it out to try and trouble shoot the code. I also tried to right an if statement to see if I can put parameters on the code but now I am at a loss I realize I could of used an array on this but I am still a little shaky on using them. On the If statement I tried to use Null to see if I can give it perameters but no luck.