I'm kinda new at this and I've been trying a lot, but I can't seem to figure this out. I have a query which says it's too complex when I run it. I've tried many ways to divide it into smaller queries, but I still can't get the whole thing running.
I saw a post where someone else had a similar problem. A suggestion to that user was to use a function to determine the value as opposed to using "Iif" in the query. I tried to adapt my fields to the sample function in the reply, but I keep getting errors. Here's my sample (I've run this several times commenting and uncommenting lines):
Option Compare Database
'Option Explicit
Public Function AugDefComp(dcjulff, fm) As Long
Dim xValue As Long
'Dim [fy 2002 employees eff date] As Database
'Set [fy 2002 employees eff date] = CurrentDb()
If dcjulff < 600 Then
'If [dc jul-ff] < 600 Then
'If fm = "01" Then xValue = (3*federal) 'value=0
If fm = "01" Then xValue = (3 * ([fy 2002 employees eff date].federal)) ' external name not defined
' If fm = "01" Then xValue = (3 * [federal]) ' external name not defined
' If fm = "01" Then xValue = (3 * Me.federal)' not right
ElseIf fm >= "02" Then xValue = 0
End If
AugDefComp = xValue
End Function
In the query, I've created a field which is defined as "AugDefComp([dc jul-ff],[fm])."
The only time I don't get an error is the line, above, where the comment says I get a value of 0. However, the value should not be 0 (if I were coding this correct). Basically, it doesn't know that 'federal' is a field in a table called 'fy 2002 employees eff date' because I keep getting the message "extrernal name not defined" while it highlights the word "federal."
Thank you very much,
~Mark
ps: as i'm trying to learn more about Visual Basic, what is the name of the coding used in Access - Visual Basic, or Visual Basic for Applications, or VBA? any good books out there for whatever this coding is called?
I saw a post where someone else had a similar problem. A suggestion to that user was to use a function to determine the value as opposed to using "Iif" in the query. I tried to adapt my fields to the sample function in the reply, but I keep getting errors. Here's my sample (I've run this several times commenting and uncommenting lines):
Option Compare Database
'Option Explicit
Public Function AugDefComp(dcjulff, fm) As Long
Dim xValue As Long
'Dim [fy 2002 employees eff date] As Database
'Set [fy 2002 employees eff date] = CurrentDb()
If dcjulff < 600 Then
'If [dc jul-ff] < 600 Then
'If fm = "01" Then xValue = (3*federal) 'value=0
If fm = "01" Then xValue = (3 * ([fy 2002 employees eff date].federal)) ' external name not defined
' If fm = "01" Then xValue = (3 * [federal]) ' external name not defined
' If fm = "01" Then xValue = (3 * Me.federal)' not right
ElseIf fm >= "02" Then xValue = 0
End If
AugDefComp = xValue
End Function
In the query, I've created a field which is defined as "AugDefComp([dc jul-ff],[fm])."
The only time I don't get an error is the line, above, where the comment says I get a value of 0. However, the value should not be 0 (if I were coding this correct). Basically, it doesn't know that 'federal' is a field in a table called 'fy 2002 employees eff date' because I keep getting the message "extrernal name not defined" while it highlights the word "federal."
Thank you very much,
~Mark
ps: as i'm trying to learn more about Visual Basic, what is the name of the coding used in Access - Visual Basic, or Visual Basic for Applications, or VBA? any good books out there for whatever this coding is called?