When the VBA code in my OnClick event of the ComboBox is run I get the following error: "Compile error: Method or data member not found"
The code in this event is:
CurrentDb.Execute "INSERT INTO tblParts (P_Number,PName,Color,Weight,City) VALUES ('" & Me.pNum & "','" & Me.PName & "', '" & Me.clr & "', '" & Me.wt & "', '" & Me.cbocty & "')"
If I run the code with the "Me.cbocty" removed it compiles. Can someone please explain what is wrong here.
As far as I can see from the code provided the problem seems to be that the VBA code cannot find a control called cbocty and therefore Me.cboctydoesn't compile causing the error.
To fix this you need to check that the name of your "parts city" combobox matches up with the reference in the VBA code. If they are different pick change the VBA code to the combobox name.
Related
I have an issue with "where condition" in macro on OpenForm in Access 2016.
I'm struggling with exactly the same issue, meaning a dialog window opening in between forms as in the link below:
Access- Open form with where clause
I have a condition like this in macro builder on OpenForm:
="ID_code_SC = " & [Forms]![SearchFRM_Materiel]![ID_code_SC]
and it still asks me to type the name of the ID. If I type it, it goes to a correct record.
Importantly, my ID is a text, such as ABC_01. So I modified it according to:
http://www.baldyweb.com/wherecondition.htm
and I have:
="ID_code_SC = '" & [Forms]![SearchFRM_Materiel]![ID_code_SC] & "'"
but this, on the other hand, opens an empty form and doesn't refer to any record.
I use Access 2016. I'm very new to Access and macros/VBA, so most likely I don't see some basic mistake.
Try this:
"ID_code_SC = '" & [Forms]![SearchFRM_Materiel]![ID_code_SC] & "'"
I am trying to pull data from an unlinked table to a form with unbound fields. I already have a form where you enter the data and send it to the table but this is to be able to pull it back and update.
This is what I have
DoCmd.RunSQL "SELECT * " & _
" FROM [" & Address & "].[BusinessAccountOpening]" & _
" WHERE [ID]= " & Me![txtID] & ""
Forms!frm_ViewUpdateRecords!Sub_Details.Form.subaddthedata
But getting the error. An RunSQL action requires an argument consisting of an sql statement.
Please help
DoCmd.RunSQL and CurrentDb.Execute are for action queries (delete, update, append) while you present a select query.
So call DoCmd.OpenQuery ... or assign the records to a recordset.
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] & "'"
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+"®ion="+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 & "®ion=" & 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+"
®ion="+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 & "
®ion=" & 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.
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.