DLookup Syntax Problem

Jun 7, 2006

I am trying to implement DLookup for the following sql to a linked SQL Server table to verify that the currentuser is in my Traders table:

select tr_username from Traders where tr_username='edobbie'

When I enter the following DLookup command I get the error 'compile error expected ='

The offending line is:

DLookup("tr_username","Traders","[tr_username] = " &CurrentUser())

The Editor doesn't seem to see the = sign in my criteria. I've modified the syntax a number of ways to no avail.

Does anyone see the problem?

View Replies


ADVERTISEMENT

How To Use DLookup Syntax

Feb 20, 2014

I need to use a dlookup on a report to look up fields on another query, other than what the report uses.

How do i use the dlookup syntax?

I have a field on another query called "Average" and the query name is AverageResults. The report is called Totals.

View 9 Replies View Related

DLookUp Syntax Error Help

Mar 26, 2008

Hello,

I have a table called "ShrinkWrapBinding" where I am supposed to look up a "Price" from. As you see in the code below, I calculate a "totalPackages" number which comes from values in a form. My problem is that when I try to use this value (totalPackages) on the DLookUp function (as seen in this code) it gives me a syntax error exactly on the totalPackages variable. Please note that I added single quotes to the 'totalPackages' variable when I use it on the DLookUp function, and have tried every possible combination (single quotes, double quotes) but still doesn't work. What is it that I'm doing wrong?

Code:
Dim totalPackages As Integer
Dim tempPrice As Double

totalPackages = Me.QuantityBooks1 / Me.ShrinkWrapQty

tempPrice = DLookup("[ShrinkWrapBinding]! [Price]", "ShrinkWrapBinding", "'totalPackages' >= [ShrinkWrapBinding]![RangeField]")


Thank you

View 8 Replies View Related

Syntax For Dlookup In Table

Jul 1, 2007

Hi all, instead of doing a dlookup via a query, i'd like to do a dlookup for price direct in a table where the criteria is the value in Text1 from Form1

outt = Nz(DLookup("[Price]", "Table1")) Where Product = ' Text1' from Form1

Whats the correct syntax for this please? Thanks

View 2 Replies View Related

Modules & VBA :: LIKE In DLookup After Syntax

Nov 5, 2013

I am looking to use a "If" statement with DLookup to find a record and see if the field name begins with "TW" as the characters. Here is what I have so far:

Code:

Dim matchCriteria As String
matchCriteria = "LIKE 'TW*'"
If DLookup("end_user", "tbl_module_repairs", "prikey = " & Me.txt_rid1.Value) = matchCriteria Then
MsgBox "Success"
Else
MsgBox "FAILURE"
End If

I am trying to switch between two sets of pricing for customers that begin with "TW" and then all else. Would the use of a "case" statement be better? If so I do not have the "end_user" bound to the form so I would need to embed Dlookup in the "case" method.

View 5 Replies View Related

Syntax Error In My Dlookup Inside Qry

Dec 22, 2007

I wonder if you can help me. In my query, for this calculated field, i get an error message about a syntax error missing operator in query expression.
what did i do wrong? thanks

FormulaID is a text field.

UnitRM Combined: nz(DLookUp("UnitRM Combined","QryFormulaSummed","[QryFormulaSummed].[FormulaID]='" & tblCostJunction.FormulaID & "'"))

View 5 Replies View Related

DLookup Syntax Problem In Report

Jan 3, 2007

I have a report that when run, prompts a user for an id. The user enters and id and it pulls the information based on that id. The information is being pulled from data stored in Table A. I also have Table B that associates an id with a name. In my report I have the input being stored as a string, called strCampusId. I have a text box with called txtCampusMinistryName. I want the report to do a lookup based on the users input and display the CampusId Name, however I am getting an error. The error says, RunTime Error 3075, Syntax error (missing operator) in query expression 'ParishId=*0101'.


Table B (called CampusMinistry) only has 2 columns, ParishId and ParishName

Here is my code that I am trying to use.

txtCampusMinistryName = DLookup("ParishName", "CampusMinistry", "ParishId=" & strCampusId)

Thanks for any and all help.

View 2 Replies View Related

Modules & VBA :: Syntax With Filter In DLookup

Feb 26, 2014

If I type 2014 instead of b everything works out.

Code:

Dim a As Double
Dim b As String
b = Right(RepMonth, 4)
a = DLookup("[EUR/TRY]", "Plan_FX_RATES", "YEAR = '" & b & "'")
Debug.Print a
Debug.Print b
Debug.Print RepMonth

View 4 Replies View Related

Forms :: Multiple DLookup Syntax

Feb 24, 2015

Me.txtversion = "Ver:" & " " & DLookup("[txtVersionMajor] & " - " & [txtVersionMinor] & " - " & [txtVersionRevision]", "tblVersionInfo")

What's wrong with my syntax ? It's the "-" part that is the problem.

View 3 Replies View Related

Forms :: Date Field Syntax For DLookup

Apr 11, 2014

I have table [table1] which have 4 fields

EMPID - primary key
EMPFirstname
EMPLastname
EMPDOB

Input box as txtempid as string

I am trying to learn how I to display other field based on one field in my case last three field based on EMPID

I am actually getting syntax error when I dry to display DATE Field

Following are my attempts

Dim Verfirstname as string
Dim Verlastname as string
Dim VerDOB as date

Verfirstname = dlookup("[EMPfirstname]","table1","[EMPID]='" & me.txtempid & "'")
Msgbox Verfirstname

works fine. But when I use for Date, I am getting syntax error

VerDOB = dlookup("[EMPDOB]","table1","[EMPID]='" & me.txtempid & "'")
Msgbox VerDOB ---- now I am getting syntax error

I tried to understand over net and I believe i need to used with "#" before and after the date field but my criteria...

View 1 Replies View Related

Queries :: DLookup - Combine Multiple Criteria Syntax In Query

Apr 17, 2013

I am trying to create a Dlookup in Access 2010 within a query using query wizard. I want to lookup the tax rate for an employee based on a salary range and their 'tax category' (string). Through troubleshooting I can get the criteria to work separately.

These are: DLookUp("Base","TABWT","[TABWT].[Taxclass] = '" & [FirstOfTaxGroup] & "'")

DLookUp("Base","TABWT",[grosspay] & " Between [TABWT]![Minimum] And [TABWT]![MaxBracket]")

These work and return the correct values for each column/row when I run the query.

However, when I combine the criteria (using the build wizard) as follows:

Expr1: DLookUp("Base","TABWT","[TABWT].[Taxclass] = '" & [FirstOfTaxGroup] & "'" and [grosspay] & " Between [TABWT]![Minimum] And [TABWT]![MaxBracket]")

The Dlookup will returns 0 values but will not give an error message.

I've tried quite a few variations on syntax and quotes and so on. However, it's just not working for me.

View 3 Replies View Related

Need Help With Syntax Please

Jun 28, 2005

Hi,
in the following code:

Dim dbtmp As DAO.Database
Dim tblObj As DAO.TableDef
Dim rs As DAO.Recordset
Set dbtmp = OpenDatabase("C:WINDOWSBureaudevcli.xls", False, True, "Excel 8.0;")
DoEvents
Set rs = dbtmp.OpenRecordset("select * from [DEVCLI$A1:C10]")

in the last line i would like replace DEVCLI (the Excel sheet name) by a variable to make my program works with any excel file.
What is the syntaxe for that ?
Thanks in advance for help.
VINCENT

View 2 Replies View Related

IIf Syntax

Nov 1, 2005

Think my syntax is wrong here, but not sure where. I would appreciate any help! Thanks!
SELECT a.[FA Ctr], a.[SAP Co], a.[SAP Ctr], a.[GL Co],



IIf([Len([SAP CO])] ="3",""0"' & [a].[SAP CO]", IIf([Len([SAP CO])]="2",""'00"' & [a].[SAP CO]"), IIf([Len([SAP CO])]="1",""'00"' & [a].[SAP CO]", "[A].[SAP CO]"))) AS Expr3
INTO [Interim Table]
FROM Asset_Map AS a

View 11 Replies View Related

IIF Syntax

Mar 12, 2008

Hi there

I'm trying to write a query using an IIF statement in the "Field" property of the Access Query Design Grid the new Column is called F:

there are 3 Columns, System, Etot, Itot in a mytable

Basically in English the query goes,

IF mytable.[System] = 700,
mytable.[Etot] = 0,
mytable.[Itot] = 0
then the newly created derived column
mytable.[F] "N/A"
OTHERWISE
mytable.[F] "OK"

I hope someone understands,

Batwings

View 6 Replies View Related

Syntax For LIKE

Dec 6, 2004

Hi,
I wud like to know why this syntax is not working.
select * from table_name where col_val like 'a%'

This returns the column values that start with 'a'. I was getting the result properly few days ago. But now suddenly this query doesnot give the result. When i tried this out in a website it was working there, but not in access.

Can anybody see what is wrong in this syntax? If the syntax is right where wud be the fault?

View 6 Replies View Related

Need Help With Syntax

Dec 20, 2004

Can someone tell me how to insert the contents of a variable into a table?
I am trying to add selected items from a listbox (Members) into a temporary table (tempMembers). The code is below. On debugging, it picks up the contents of the variable (iMemberID) OK, but adds "0" to the temp table (both are integers). I'm pretty sure the problem is in the Insert statement below (stSQL3), but I can't figure out how to write it!

Any help would be greatly appreciated!
Thanks

stSQL3 = "INSERT INTO tempMembers (MemberID) VALUES & iMemberID & ;"
For Each varItm In Me!Members.ItemsSelected
iMemberID = ctl.ItemData(varItm)
DoCmd.RunSQL stSQL3
Next varItm

View 6 Replies View Related

Syntax

Sep 29, 2005

Can anyone tell me the proper syntax for:

1. Calling another Form from within a Form

2. Calling a module from within a Form

Thanks in Advance

View 5 Replies View Related

Help With Syntax

Sep 4, 2006

Can someone help me on the syntax for the following?
I have two tables: one is TapeNumber and has one field (Tape_No) autonumbered PK. The other table has information about the video and uses the Tape_No as a secondary key.

I have a form to add information about videos. I have the form bound to the first table, so it adds a new TapeNumber when I add a record. I have a subform displaying the video information for that tape (there may be several videos recorded on one tape).

When I add a new tape (or video to an existing tape), how do I save the tape number to the second table?

Thanks!

View 1 Replies View Related

Vba Syntax????????help

Mar 1, 2007

have this code which keeps on giving me this error...I dont know whats wrong with the code please help tried removing the quotes (rstStudents.Open "SELECT * FROM Students WHERE Regno = " & _
txtReg , _
CurrentProject.Connection, _
adOpenStatic, adLockReadOnly, adCmdText) but then it wont retain any records even if they exist in the table

here is the original code

rstStudents.Open "SELECT * FROM Students WHERE Regno = '" & _
txtReg & "'", _
CurrentProject.Connection, _
adOpenStatic, adLockReadOnly, adCmdText




ERROR MESSAGE>>>>>>> Runtime Error '-2147217913 (80040e07)
Data type mismatch in criteria expression


the code is supposed to use number input by user to search in a table and fill all the other fields in the form with the table data (it is run on lost focus of the text box were value has been input)



the whole code :::::




Private Sub txtReg_LostFocus()
Dim rstStudents As ADODB.Recordset
Dim blnFound As Boolean
Dim fldItem As ADODB.Field

blnFound = False

If Me.txtReg = "" Then Exit Sub

Set rstStudents = New ADODB.Recordset
rstStudents.Open "SELECT * FROM Students WHERE Regno = '" & _
txtReg & "'", _
CurrentProject.Connection, _
adOpenStatic, adLockReadOnly, adCmdText

With rstStudents
While Not .EOF
For Each fldItem In .Fields
If fldItem.Name = "Regno" Then
If fldItem.Value = txtReg Then
Me.txtName = .Fields("Name")
Me.txtAdd = .Fields("Address")
Me.txttel = .Fields("Telno")
Me.txtTutor = .Fields("TutorName")
Me.txtbks = .Fields("NoBooksonloan")
blnFound = True
End If
End If
Next

.MoveNext
Wend
End With

If blnFound = False Then

MsgBox "No student record to display"
' ... and reset the form
' cmdReset_Click
End If

rstStudents.Close
Set rstStudents = Nothing

End Sub

View 2 Replies View Related

Syntax

Sep 5, 2007

I am trying to open a PDF from Access. I get it to work but it requires me to hard code the path and fiel name....

The path will always be the same although the file name will change. RIght now I get the fiel name from a textbox on a form...I am trying to change the below working code with a varaible instead of the path....I think there is some systax issues that I cannto fingure out

TotPath is the variable that holds the entire path to the file "X:Map_LibraryPark_and_Rec_AsbuiltPRA_19_73-01_W0.pdf"

This variable is rebuilt everytime the user selects something on the form....so the actual File name will change every time...

Does anyone have and ideas as to how to incorporate a variable instead of the hard coded path?

THank you all for your help.....


Code:WORKING CODE: 'Shell "C:Program FilesAdobeAcrobat 7.0AcrobatAcrobat.exe X:Map_LibraryPark_and_Rec_AsbuiltPRA_19_73-01_W0.pdf", vbMaximizedFocus ' open a txt documentNOT WORKING CODE:Shell "C:Program FilesAdobeAcrobat 7.0AcrobatAcrobat.exe TotPath", vbMaximizedFocus ' open a txt document

View 3 Replies View Related

Access97 SQL Syntax

Jul 25, 2005

I'm familiar with SQL but not with Access97 - some wierd syntax here!

I'm creating a Query that is to Delete records from a table depending on a non-key field in a second table.

I first tried an INNER JOIN


DELETE Activity_Preferences.*
FROM Activity_Preferences INNER JOIN Activity_Key
Activity_Preferences.Activity_Key=Activity_Key.Act ivity_Key AND Activity_Key.Complete=1;


which was initially accepted but then complained about the INNER JOIN after I went in a second time to 'fix' the error.

I've finally got the following syntax accepted:-


DELETE Activity_Preferences.*
FROM Activity_Preferences, Activity_Key
WHERE Activity_Preferences.Activity_Key=Activity_Key.Act ivity_Key AND Activity_Key.Complete=1;


But when executed still gets the following error (same as for the INNER JOIN):-

'Operation must use an updatable query'.

What else is needed?

J.
:confused:

View 4 Replies View Related

Syntax Question

Aug 1, 2005

Hi,
In a form i use the following filter fonction :
DoCmd.ApplyFilter , "CliNom = '" & RunCli & "'"
The problem is that sometimes RunCli (wich is a name) contains ' symbol and then generates a syntaxe error, is there a way to prevent that ?
Thanks in advance.
VINCENT

View 3 Replies View Related

Syntax Error

Mar 2, 2007

On my form I have 2 radio buttons rdoAll and rdoSpecific. If rdoAll is true then it prints a report. THis part works fine. However if rdoSpecific is true then I make visable combo box to look up an ID. Then when I click the button I want the same form to open but with just the info pertaining to the ID selected. Here is my code:

Private Sub cmdLotHistory_Click()

Dim stDocName As String, stSelection As String

stDocName = "rptLotHistory"

If Me.rdoAll = True Then
DoCmd.OpenReport "rptLotHistory", acViewPreview
End If

If Me.cboLotLU.Value > 0 Then
stSelection = "[LotID] =" & Me![cboLotLU]
End If

DoCmd.OpenReport stDocName, acViewPreview, , stSelection

End Sub

When I choose the ID and click the button I get the message

Run-Time error '3075':

Syntax error (missing operator) in query expression '(LotID
=020806B1585)'.

the 020806B1585 is my ID number.

Debug hightlights the
DoCmd.OpenReport stDocName, acViewPreview, , stSelection

but I'm guessing my real problem lies in the
stSelection = "[LotID] =" & Me![cboLotLU]


Can anyone point me in the right direction?

Thanks,
Rick

View 2 Replies View Related

SQL Syntax Issue

Jun 18, 2007

I am using the folling code in a after update combobox event:

Dim rst As DAO.Recordset
Dim sqlwhere As String

sqlwhere = " "

If IsNull(Me.comboSearchSerial) = False Then
sqlwhere = "SerialNumber='" & Me.comboSearchSerial & "' and "
End If


mysql = "SELECT TBL_RMA.* from [TBL_RMA] Where "
mysql = mysql & sqlwhere
mysql = mysql & ";"
Forms!FRM_RMA.RecordSource = mysql

Exit_comboSearchSerial_AfterUpdate:

This is currently working for me with SerialNumber being a text field. I would like to use the same code substituting SerialNumber with a Date field. I know its probly an issue with the use of quotes, but I can't seem to figure it out. Also, if I wanted to use a number format, what would I use...
Thanks
Gregg

View 2 Replies View Related

INVALID SQL Syntax

Sep 13, 2007

I am receiving this error;

"Invalid SQL syntax, cannot use multiple columns in a column level CHECK constraint."

Without explaining my disaster of a situation anyone have any ideas?

View 4 Replies View Related

Syntax Help On Rs.findfirst

Mar 25, 2008

Hi, I need some syntax help on the following line of code:

rs.FindFirst (rs![NewRecord] = True And IsNull(rs![Event_No]))

where NewRecord is type boolean and Event_No is string. Ive used this function mainly on strings so am not sure what to do with this one!
thanks!!

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved