Errors in DLookup as a control source in access form - ms-access

I have a text box with the control source of Dlookup function. But the Dlookup format makes me crazy, I tried a hundred times to refer another combo box value as criteria in Dlookup function. I got either "# name?" or "# Error".
I tried this:
=DLookUp("[Contact]","Supllier","[Company]='" & [Forms]![PurchaseOrder]![cboSupplierCompany] & "'")
and got "# Error"
when I input :
=DLookUp("[Contact]","Supllier","[Company]='" & [Me]![cboSupplierCompany] & "'")
I got "# Name?"

I finally found the solution. The right way to use Dlookup in a expression is to use the expression editor to select table field and form control.
the working expression of Dlookup in my textbox is :
DLookUp(" [Supplier]![Contact] ","Supplier"," [Supplier]![Company] ='" & [cboSupplierCompany] & "'")

Using a SQL-query window above-like versions work fine.
But they did not work in the ControlSource property setting. Here you have to use semicolons (;) instead of commas (,). At least in a German language settings environment. The control setting in German is:
Steuerelementinhalt
= DLookUp(" [Supplier]![Contact] ";"Supplier";" [Supplier]![Company] ='" & [cboSupplierCompany] & "'"

Related

SSRS not recognizing dataset in expression for barcode

Whenever I use this code
=IIf(JPCI_RPT_ReceiptStatusHeaderBLW.RECEIPT_ID_TYPE = "Trailer ID",
Code.StringToBarcode({JPCI_RPT_ReceiptStatusHeaderBLW.trailer_id}),
Code.StringToBarcode({JPCI_RPT_ReceiptStatusHeaderBLW.receipt_id_type}) & chr(10) &
Code.StringToBarcode({JPCI_RPT_ReceiptStatusDetailsBLW.item})
I get the following error...
Name 'JPCI_RPT_ReceiptStatusHeaderBLW' is not declared.
It's checking for dataset right? If not, how do I declare it?
The expression is looking for a field name and you're converting something like Crystal Reports to SSRS. In SSRS you refer to a field value with Fields!FieldName.Value.
Assumeing that you have a dataset with necessary fields, your expression would be something like:
=IIF(Fields!RECEIPT_ID_TYPE.Value = "Trailer ID",
Code.StringToBarcode(Fields!trailer_id.Value),
Code.StringToBarcode(Fields!receipt_id_type.Value) & chr(10) &
Code.StringToBarcode(Fields!item.Value) )
You had missed a closing parenthesis as well, but the error check didn't get that far.

Access 2010 txt Search Box to Search multiple fields?

I have multiple combo & text boxes to search for different values in my main table on my front end. The code is as follows, just replicated for different types etc. This all works fine.
If Not IsNull(Me.strSearch) Then
strWhere = strWhere & "([tbl_Main.Description] Like ""*" & Me.strSearch & "*"") AND "
End If
My Problem is, I'm trying to create a text box which searches 2 columns simultaneously in my tbl_Main (tbl_Main.LessonsLearnt & tbl_Main.RecommendedAction) but can't figure out how to modify my current code to add another column in, searchable from the same textbox.
Disclaimer: I'm very much a beginner in MS Access - so please keep the explanation as simple as possible :D
If you need any other info - just let me know!
Thanks in advance
strWhere = strWhere & "(tbl_Main.Description Like '*" & Me.strSearch & "*' OR tbl_Main.OtherField Like '*" & Me.strSearch & "*') AND "
This will search for the strSearch being in either Desscription or OtherField. I also replaced your double double quotes with single quotes for better code readability and cross compatibility with other DBMS and removed the brackets that are only needed if you have spaces in your table/field names (something you really should never do anyway).

Ms-Access 2010 Single quote syntax error

I'm trying to create a plant database using MS-Access 2010. I'm trying to open a form by clicking on a button. From what I've researched online, I realize the problem lies with the single quotes, but I don't understand coding enough to figure our what I'm supposed to do to bypass the issue.
Here is the code I'm using.
="[Latin Name]=" & "'" & [Latin Name] & "'"
The last part of the Latin name ("cultivar" says a dictionary) usually is enclosed in single quotes itself. So you cannot simply concatenate the name into a query expression where it is separated by single quotes.
If you have ever heard of SQL injection, that's what is happening here.
You need to escape the single quotes with the Replace() function:
="[Latin Name]=" & "'" & Replace([Latin Name], "'", "''") & "'"

How to add a subreport in a new window?

I am developing a SSRS 2008 R2 RDL with a chart. Currently, I have a subreport built into this chart where if they click on a pie piece it goes directly to this subreport. It is currently configured as an action on the series via "Go to Report".
However, my customer wants it to instead open a new browser window so that they can still see original chart without having to rerun my report. Also, this subreport requires several input parameters. I tried the "Go to URL" Action link instead and entered the URL there. But this didn't work cause I couldn't pass in my input parameters. How can I do this?
This subreport takes multiple parameters. I have it configured as:
="javascript:void(window.open('http://evolvdb/Reports/Pages/Report.aspx?ItemPath=%2fIncoming%2fCensus_by_Date_Range2_Subreport&rs:Command=Render&startdate="+Parameters!startdate.Value+"&enddate="+Parameters!enddate.Value+"&region="+Parameters!region.Value+"&state="+Parameters!state.Value+"&office="+Parameters!office.Value+"&status="+Parameters!status.Value+"&program_hyperlink="+Fields!program_code.Value+"&funding_source_param="+Parameters!funding_source.Value+"'))"
But when I try to click this subreport it is not clickable.
I also tried this, but this exceeds the 255 character count:
="javascript:void(window.open('http://evolvdb/Reports/Pages/Report.aspx?ItemPath=%2fIncoming%2fCensus_by_Date_Range2_Subreport&rs:Command=Render&startdate=" & Parameters!startdate.Value & "&enddate=" & Parameters!enddate.Value & "&region=" & Parameters!region.Value & "&state=" & Parameters!state.Value & "&office=" & Parameters!office.Value & "&status=" & Parameters!status.Value & "&program_hyperlink=" & Fields!program_code.Value & "&funding_source_param=" & Parameters!funding_source.Value & "'))"
I also tried this, but this was not clickable either:
="javascript:void(window.open('http://evolvdb/Reports/Pages/Report.aspx?ItemPath=%2fIncoming%2fCensus_by_Date_Range2_Subreport&rs:Command=Render
&startdate="+Parameters!startdate.Value+"
&enddate="+Parameters!enddate.Value+"
&region="+Parameters!region.Value+"
&state="+Parameters!state.Value+"
&office="+Parameters!office.Value+"
&status="+Parameters!status.Value+"
&program_hyperlink="+Fields!program_code.Value+"
&funding_source_param="+Parameters!funding_source.Value+"'))"
I'm looking at the last code snippet that you tried and here is my feedback:
The report path doesn't look correct. Should be in the format http://evolvdb/ReportServer/Path/To/Report&Parameters=XX
You can't concatenate strings in SSRS with + and need to use & instead.
Example:
="javascript:void(window.open('http://evolvdb/ReportServer/Incoming%2fCensus_by_Date_Range2_Subreport&rs:Command=Render
&startdate=" & Parameters!startdate.Value & "
&enddate=" & Parameters!enddate.Value & "
&region=" & Parameters!region.Value & "
&state=" & Parameters!state.Value & "
&office=" & Parameters!office.Value & "
&status=" & Parameters!status.Value & "
&program_hyperlink=" & Fields!program_code.Value & "
&funding_source_param=" & Parameters!funding_source.Value & "'))"
My general advice for creating SSRS links is to take your browser and start there with zero programming. Ensure that your report path is correct, then manually add a parameter and ensure the report accepts the parameter value correctly. Once you have a working URL example, create a textbox in your report that spits out the URL string you are trying create. This is an easy way to ensure you are getting the expected output and you can compare to the URL that you manually crafted in the first step. Lastly, put the finished expression into the "Go to URL" action and you should most likely have a link that works as expected.

MS Access Syntax error

here is my code:
Text22 = DLookup("[Program_No]", "1_Supportive_Housing", "[Program_Name] = '" & Replace([Me.Program_Name], "'", "''") & "' And [BudgetYear] = " & [Me.BudgetYear])
I am not sure what is wrong with it, but it keeps giving me the following error:
Can't find the field | in your expression
I have been trying to get rid of this error but nothing works.
OnKeyPress, this event triggers. As the user writes, it should be able to lookup the value in the table and assign it to text22.
Looks like you want to reference to form fields [Me.Program_Name] & [Me.BudgetYear], but Access tries to find fields with exactly this name, including "Me." prefix. Try to remove brackets at all, or use Me.[Program_Name] and Me.[BudgetYear] instead.