Hi everyone. I need help in the syntax of the DLookup() and I appreciate your efforts
I am trying to get a value from a query to place in a form using the DLookup function. This value must meet two criteria: must be on the last date, and, it is the one for the text field that match the specific text field on the form from which this procedure is initiated. Please note the following:
I am stumped with the syntax of the criteria for matching the string from the query with that of the form. Here is part of the code that is causing the error:
Dim doShare as Double
Dim stShare as String
stShare = me.Desc ‘Desc is the text field in the form that contains the string to match
doShare = DLookup("[QueStocksDaily]![TotValue] ", "QueStocksDaily", _
" [QueStocksDaily]![DDate] =" & "#" & DMax(" [QueStocksDaily]![DDate] ", "QueStocksDaily") & "#" AND _
"*[QueStocksDaily]![Symbol]* like " & stShare)
The date part is working fine. The last one is the issue, at least for me. I am showing here the simplest form, so you can see what I am trying to do, as I tried many variations of using the single quotes and double quotes that I could think of, without success.
Once again, the field on the form, contains (not equal to) the field in the query. Here is a sample data that may help too:
Desc = Microsoft (MSFT)
Symbol = MSFT
Thank you again for all and any effort
I am trying to get a value from a query to place in a form using the DLookup function. This value must meet two criteria: must be on the last date, and, it is the one for the text field that match the specific text field on the form from which this procedure is initiated. Please note the following:
- The underlying table of the query, and the underlying table of the form are not related
- The string field from the query must match a “part” of the string field in the form
I am stumped with the syntax of the criteria for matching the string from the query with that of the form. Here is part of the code that is causing the error:
Dim doShare as Double
Dim stShare as String
stShare = me.Desc ‘Desc is the text field in the form that contains the string to match
doShare = DLookup("[QueStocksDaily]![TotValue] ", "QueStocksDaily", _
" [QueStocksDaily]![DDate] =" & "#" & DMax(" [QueStocksDaily]![DDate] ", "QueStocksDaily") & "#" AND _
"*[QueStocksDaily]![Symbol]* like " & stShare)
The date part is working fine. The last one is the issue, at least for me. I am showing here the simplest form, so you can see what I am trying to do, as I tried many variations of using the single quotes and double quotes that I could think of, without success.
Once again, the field on the form, contains (not equal to) the field in the query. Here is a sample data that may help too:
Desc = Microsoft (MSFT)
Symbol = MSFT
Thank you again for all and any effort
