473,796 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ 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("Fed Budget", "tblBudget" , "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspendi ng " & 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 "Overspendi ng " & vbCrLf & vbCrLf & Me.Category & vbCrLf
& vbCrLf & "by more than $500", vbExclamation
any help?

Nov 13 '05 #1
2 3541
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.goo glegroups.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("Fed Budget", "tblBudget" , "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspendi ng " & 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 "Overspendi ng " & 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.goo glegroups.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("Fed Budget", "tblBudget" , "([SubgNo] = " & Me.SubgNo & ")
And ([BudgetID] = " & Me.BudgetID & ")"), 0) - ([FedFSRToDate]) < -500
Then

' MsgBox "Overspendi ng " & 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 "Overspendi ng " & 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
2474
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 exists, with data, as do the fields "GiftAmt" and "GiftDate". However, when I try to preview the report, I get 2465 error that says it cannot find the field "GiftDate". I have tried every combination of quotes, double-quotes, parentheses, etc.
2
2221
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 MouseNumber, can I use
3
1929
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. --- Function ThisIs() Dim TDate As Date, C1 As Integer, StrSQL As String, TypeAttend, RecDetect If Not IsNull(Me.scrStudent) Then C1 = 1: TDate = Me!
2
2947
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 strUser = WUserName() If IsNull(DLookup("Permitted", "tblUsers", "Permitted = '" &
3
1318
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 I seem to remember suggestions in this forum that discouraged the latter. But I tire of it. To me, the latter is more readily understood because there's no double negative to deal with.
2
1362
by: Eric | last post by:
Can any one please tell me the syntax is correct Me.List17=DLookUp(,,="" And =") Thanks,
3
1807
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 AfterUpdate event of the txtCostCenter runs the following code. Me.txtProjectNumber = DLookup("ProjectNumber", "tblList", "CostCenter =" & Me. txtCostCenter) Me.txtGLCode = DLookup("GLCode", "tblList", "CostCenter =" & Me.txtCostCenter)
2
2915
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 are "County Code" and "County Name" The combo box allows you to pick a county from a list tied to the "County Codes" table, and stores the "County Code" in the ComboBox field. I want it to then automatically put the county name into the "County...
5
8836
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 debugging myself). My problem is in the DLookup command. UserName = Me.cboUserName.Value Debug.Print "User Name is "; UserName strPassword = DLookup("Password", "Employees", "EmpName ='" & UserName) Debug.Print "Password is ";...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9057
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7555
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4122
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 we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.