How to use Attachment Image from Table in Access Form and Report Headers? - vba

I have an Access database used by many projects and each project have its logo and information stored in table called company_info_tb.
I stored the logo in Attachment field type; each project can modify its info and logo to be used in its printed reports.
How I can call the project logo to be shown in the headers of Access forms and reports using a Bound Object Frame or another way?
I tried using dlookup in the Control Source of the Bound Object Frame:
Dlookup("LOGO","company_info_tb")
And using LOGO that was shown in mainform, by putting this code in the Control Source:
=forms!main_frm!LOGO
But it doesnt work.

Options:
include logo attachment field table in report RecordSource, without a join clause the logo record will associate with each record of data table/query (Cartesian relationship), place bound control only in header section - not appropriate for data entry/edit form because the resulting query is not updatable
save the logo image externally and store path in text field then use DLookup expression or Cartesian query
subform/subreport in header
Recommend using Image control and set its ControlSource property either by binding to attachment field or text field or expression to construct external path. A BoundObjectFrame control must be bound to an OLEObject field and options 1 or 3 would work.

Related

How to mimic values in multi page SSRS Report

I need a lab report that has several pages. Each test has a unique reference number and I would like it to appear in the header according to what I have on the page. At the moment I only see one reference number and it remains unchanged after switching to another page. See attached image.
If possible, I would like to get rid of the SampleNo column so that its value is only in the header
The easiest way to do this is to reference the the textbox in your tablix that contains the "Sample No.".
Click the textbox that you have highlighted in the tablix, show the properties window (F4 in Visual Studio - can't remember in Report Builder, I think View/Properties).
Find the Name property of the textbox, this is often the name of the field it contains but not always.
In the example below the textbox name is 'oYear`
Next, set the expression in your header to be something like
=FIRST(ReportItems!oYear.Value)
Change oYear to whatever textbox name in your tablix is.
ReportItems refers to the rendered object name so here we just get the first on each page.
Here the first two pages from a small sample of data which groups by year.

MS Access - FIlter subform based off listbx

I am trying to filter a subform based off a value selected in a listbox.
My list box is called cboCurrentListName and this is populated using a select query
The subform is called Form_subform_ListContents
For the change event for the list box I have the following code, however no filters are applied when its executed.
Me.Form_subform_ListContents.Form.Filter = "[ListName]=" & Me.cboCurrentListName.Value
Me.Form_subform_ListContents.Form.Filter = True
I have also tried using Master/Child links to execute this using the following steps, but this caused an input box to pop up when the fom loaded:
first I set the 'link child fields' option in the properties of the subform to 'ListName' (this is the field name that populates the list box and is present in the subform
then I set the 'link master fields' option in the properties of the subform to 'cboCurrentListName' (the listbox name)
then in the listbox properties I set the control source to 'cboCurrentListName'
The above steps cased an input box to pop up on opening the form (the value typed in here does filter the subform). However I don't want an input box in order to do this, I want to use the listbox.
I have googled this and fried different methods but have had no luck. I am pretty new to access and of the control source sections aren't a strong point of mine, which is why I tried to use the VBA on the event change instead
Any help would be appricaited, I tried a few things and had no luck.
EDIT: When trying the master/hild option I also get an error 'Can'y build a link between unbound forms' if I click the 3 dots in the poperties. SO for the above steps I had to manually type in the otpions.

Add a field value to text box

I have an Access Table named Count. It has one field named Anz and it has only 1 record. I want to Show this record in a TextBox on a form named overview. So in the design mode of the form inside the TextBox I use the code
[Count]![Anz]
but it Returns me #Name? error when I Switch back to form mode. Where am I going wrong?
You can use in Control Source of your unbound text box =Dlookup("[Anz]","[Count]")
Also you can bound your form to Count table and use for text box control source Anz

Inserting .DBF Files from different folder structure with their respective FilePath using SSIS?

Am working on creating SSIS Package the does the following, so far my SSIS Package works well to insert records from '.DBF' file from one folder location ONLY (Am using Data Flow Task onto the Control Flow and OLE DB Source/Destination to read a .DBF file and get it inserted). However, am not able to figure out how to make it works with 20 sites, for example: I have 20 '.DBF' files stored in the following structure:
1. E:\DBF Files\Site1\Data\records.DBF
2. E:\DBF Files\Site2\Data\records.DBF
3. E:\DBF Files\Site3\Data\records.DBF
4. E:\DBF Files\Site4\Data\records.DBF
and so on till Site20 (here file name remain the same but the content will differ from site to another).
I have table for 'records.dbf' file in my SQL Server in the following structure:
Records Table:
Product_Name Price FilePath FileName
---------------------------------------------------------------
now here, how can process these files from different sites to be stored in my records sql table with it respective FilePath using SSIS??
P.S File Names will always remain the same and the path will change "Like Site 1"
Grab a For Each Loop container for the SSIS Toolbox and drag it on to the Control Flow designer.
Double click the For Each container to bring up the editor, click the Collection tab from the left-hand menu
Leave the Enumerator set at Foreach Item Enumerator and click the Columns button in the lower right.
Click the Add button and just go with the defaults which should be Column 0 and String. Click OK to return to the previous dialog. In the new Column 0 column add your folder paths one per row.
Next click the Variable Mappings tab from the left-hand menu, for the drop-down menu in the Variable column select New Variable. Again go with the defaults except for the name which in my example I have called dbf_path.
Next click OK to complete the For Each. Now the difficult bit for me because I don't what tasks you currently have that are working for one file. Whatever it is you have working, select it with the mouse and then drag and drop it into the For Each container.
For each task or tasks that need to use the file path do the following:
double click it to edit, in the left-hand menu select Expressions, then click Expressions and then click the ellipsis.
From the Property drop-down in the Property Expression Editor you need to find the property that would hold the file path for this task. The names are not always obvious and can be called different things in different tasks. In my example I am using a File System Task which I think is the Source Property.
Click the ellipsis in the Expression column and add an expression that consists of your path variable concatenated a string that contains the name of your file. One thing to note is backslashes have special meanings so if your string contains any they must be escaped with a second backslash.
Now when you run the package the For Each will loop through each path you have defined and store it in your variable which tasks will reference.

Calling a Control on a subform

I'm looking for a way to access a control on a subform, currently everything I have tried gives me an error of "cannot find".
my main form "frm_View" contains the subform "subform_View2"
subform_View2 contains a tab container
the tab container contains yet another subform "subform_View3" on the
first tab
Separate form "frmAnswers"
I need to access a control on subform_View3 in order to insert information obtained from frmAnswers.
I've tried:
me.subform_view3!frm_View!control1
me.subform_view3!subform_view2!subform_View3!control1
The thing is that you must treat the tab control as a special kind of container, with each page behaving similarly to another subform.
I have created an example, see picture below.
The main form contains a TabControl (named tabControl) and the first page contains a subform (called SubForm) and that contains a text box (txb).
To get to the value of the text box you will need to path through the tab control like this:
Me.tabControl.Pages(0).Controls("SubForm")!txb.Value
or
Me.tabControl.Pages("Page1").Controls("SubForm")!txb.Value
or
Me.tabControl.Pages("Page1").Controls("SubForm").Controls("txb").Value
Notice that the SubForm is part of the "Controls" collection of the page, so you'll need to identify the tab control first, then the page (either by name or zero-based index) and then the subform itself to get to it's controls.
EDIT
If you want to call it from a form-independent code, you can target the form like this
Forms!MainForm!tabControl.Pages("Page1").Controls("SubForm")!txb.Value