Hi
i tried above dlookup function, but its not working. Appreciate your help on this matter.Code:myValue = InputBox("Please Enter Lecturer ID") sql = DLookup("Lecturer_Name", "Lec_Details", Lecturer_ID = myValue)
Hi
i tried above dlookup function, but its not working. Appreciate your help on this matter.Code:myValue = InputBox("Please Enter Lecturer ID") sql = DLookup("Lecturer_Name", "Lec_Details", Lecturer_ID = myValue)
Maybe:
Code:myValue = InputBox("Please Enter Lecturer ID") sql = DLookup("Lecturer_Name", "Lec_Details", "Lecturer_ID = myValue")
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
myvalue must be outside the quotes to resolve, while field name is inside:
sql = DLookup("Lecturer_Name", "Lec_Details", "[Lecturer_ID] = " & myValue)
That's what I thought but before posting I looked up the syntax at: https://www.techonthenet.com/access/...in/dlookup.php where it says:Syntax
The syntax for the DLookup function varies depending on what datatype you are uisng in the last parameter. Below we show how to use the DLookup function with numeric, string, and date value in the final parameter.
Numeric
DLookup("FieldName" , "TableName" , "Criteria = n")
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
That syntax only applies where a specific number value is specified. For example
However as the input box value is being passed to a variable, myValue, this IS correct for a number fieldCode:sql = DLookup("Lecturer_Name", "Lec_Details", "Lecturer_ID = 5")
OR for a text fieldCode:myValue = InputBox("Please Enter Lecturer ID") sql = DLookup("Lecturer_Name", "Lec_Details", "Lecturer_ID = " & myValue)
Code:sql = DLookup("Lecturer_Name", "Lec_Details", "Lecturer_ID = '" & myValue & "'")
Thanks Colin. At least I'm no longer confused although I am rather surprised that TechOnTheNet don't show the correct solution for this scenario which I would think is the most common.
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
Hi Bob
I agree totally. Had assumed there was a follow-up page to include the use of variables but that seems not to be the case
As is so often the case, Allen Browne does it better: http://allenbrowne.com/casu-07.html