473,471 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

syntax for a dlookup

syntax for a dlookup
ok I give up!

here is the error...
' Run-time error 3075 Syntax error in query expression '...'

this is the code before that a contractor wrote.
(I dont know if it ever worked....the table was wrong however)
If Nz(DLookup("FedBudget", "tblBudget", "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category &
vbCrLf & vbCrLf & "by more than $500", vbExclamation

this is the code I put in causing and error.

If Nz(DLookup("[BUDGET_FEDERAL]", "[VOCA_BUDGET]",
"([VOCA_BUDGET].[SUBGRANT_NO] = " & Me.SubgNo & ") And
([VOCA_BUDGET].[Budget_ID] = " & Me.BudgetID & ")"), 0) -
([FedFSRToDate]) < -500 Then
MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category & vbCrLf
& vbCrLf & "by more than $500", vbExclamation
any help?

Nov 13 '05 #1
2 3503
Try removing the [VOCA_BUDGET]. from the criteria section of the DLookup.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"jwa6" <jw*****@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
syntax for a dlookup
ok I give up!

here is the error...
' Run-time error 3075 Syntax error in query expression '...'

this is the code before that a contractor wrote.
(I dont know if it ever worked....the table was wrong however)
If Nz(DLookup("FedBudget", "tblBudget", "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category &
vbCrLf & vbCrLf & "by more than $500", vbExclamation

this is the code I put in causing and error.

If Nz(DLookup("[BUDGET_FEDERAL]", "[VOCA_BUDGET]",
"([VOCA_BUDGET].[SUBGRANT_NO] = " & Me.SubgNo & ") And
([VOCA_BUDGET].[Budget_ID] = " & Me.BudgetID & ")"), 0) -
([FedFSRToDate]) < -500 Then
MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category & vbCrLf
& vbCrLf & "by more than $500", vbExclamation
any help?

Nov 13 '05 #2
"jwa6" <jw*****@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
syntax for a dlookup
ok I give up!

here is the error...
' Run-time error 3075 Syntax error in query expression '...'

this is the code before that a contractor wrote.
(I dont know if it ever worked....the table was wrong however)
If Nz(DLookup("FedBudget", "tblBudget", "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category &
vbCrLf & vbCrLf & "by more than $500", vbExclamation

this is the code I put in causing and error.

If Nz(DLookup("[BUDGET_FEDERAL]", "[VOCA_BUDGET]",
"([VOCA_BUDGET].[SUBGRANT_NO] = " & Me.SubgNo & ") And
([VOCA_BUDGET].[Budget_ID] = " & Me.BudgetID & ")"), 0) -
([FedFSRToDate]) < -500 Then
MsgBox "Overspending " & vbCrLf & vbCrLf & Me.Category & vbCrLf
& vbCrLf & "by more than $500", vbExclamation
any help?


Why not break it up into manageable bits and use variables to hold certain
bits of data. For example, you could dimension strWhere as a string to hold
the WHERE clause for the DLookup you could build this up in bits and do a
Debug.Print of it to check it is as expected. Also dimension something to
hold FedFSRToDate - whatever this is - a field from a bound form?
To put the whole lot in effectively one line of code is, as you have found
out, asking for trouble.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tony Ciconte | last post by:
I am using Acc97 and trying to get the following instruction to work in the OnOpen event of a report: DLookup("", "tblTempRevenueByFY", DatePart("m", ) = 1) The table tblTempRevenueByFY...
2
by: Tony | last post by:
Hi, I have a table with two primary keys as below. Table: Mouse Primary key 1: MouseLine Primary key 2: MouseNumber Field 3: DateOfBirth In a particular form, if I know MouseLine and...
3
by: shifty shaker | last post by:
I've modified sql text and now i'm getting a syntax error that I cannot figure out....anyone? error occurs at the Insert Into line but the entire function is given in case you need it. ---...
2
by: Diana | last post by:
I thought I had this process pretty well down pat, but I'm getting a syntax error on the following code: *****Code***** 'Check for users - can't get this to work... Dim strUser As String ...
3
by: MLH | last post by:
If Not IsNull(DLookup("", "tblCars", "=GetCurrVID()")) Then If DLookup("", "tblCars", "=GetCurrVID()") Then Of the above 2 syntax variations, is the 2nd unacceptable? I use the former because...
2
by: Eric | last post by:
Can any one please tell me the syntax is correct Me.List17=DLookUp(,,="" And =") Thanks,
3
by: injanib via AccessMonster.com | last post by:
Hello Access Monsters, I have a table with three columns. "CostCenter", "ProjectNumber", "GLCode" On my form I have three texboxes, "txtCostCenter", "txtProjectNumber" and "txtGLCode". the...
2
by: Bhujanga | last post by:
I have a form called BasicInfo. On the form there is a field called text box called "County Name" and a ComboBox called "County Code" There is a table called "CountyCodes" that has two fields; they...
5
by: rolltide | last post by:
I've seen many similar threads, but despite repeated efforts I cannot figure out my problem. I am running Access 2003, VB 6.5, Office XP Pro. Code excerpt is below (you can see where I've tried...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.