Is there a way to check an Access Table with many hyperlinks fields and contains hundreds of records if any of these hyperlinks are not working without clicking each link?
Note: All hyperlinks are referring to files & folders.
Access Example
You can use my function DownloadFile found at VBA.PictureUrl in an expression in a query, as the function returns 0 (zero) if the URL is live.
IsBroken: CBool(DownloadFile(Nz([YourUrlField]), "C:\Test\Delete.tmp"))
When done, delete C:\Test\Delete.tmp.
Related
I created a web query as below in Excel.
New Queries --> From Other Sources --> From Web
How do I pass in the cell value as a parameter to the Url?
I have search bunch of articles, including in the stackoverflow. None of them work.
There is 1 article says I can do this in VBA.
ThisWorkbook.Sheets("[SheetName]").QueryTables("[TableName]").Connection =
But it is not there.
Any one know how to do this?
More information:
It is connecting to a REST server, and geting back the JSON result.
I found an article discussing how to create a query link mine, but it has not options to add the parameters. Please see the link. Step 3 have the URL typed in.
https://success.planview.com/Planview_LeanKit/Reporting/Advanced_Reporting/030Configure_A_Connection_To_The_Reporting_API_With_Excel
Give the cell a name, e.g. pMyParameter.
Open the query editor and create a new blank query (New Query --> Other Sources --> Blank Query). Give that query a name similar (or same) to the cell name (let's call it pMyParameterQuery). Open the Advanced Editor and replace everything with the following.
let
Source = Excel.CurrentWorkbook(){[Name="pMyParameter"]}[Content]{0}[Column1]
in
Source
You'll see in the query list that this query does not return a table but text (or a number / date / ... depending on the contents of your named cell).
Now switch to your web query and open its Advanced Editor. Find the line that has the URL, probably something like this:
Source = Web.Page(Web.Contents("http://www.example.com?someParameter=someValue")),
Here you can use the result of the parameter-query in the URL like this:
Source = Web.Page(Web.Contents("http://www.example.com?someParameter=" & pMyParameterQuery)),
This is probably a dumb question, but I'm a noob, so forgive me. I have two tables with a one to many relationship based on a OrderNumber. Essentially, I have some order details in one table, including OrderNumber (the one side of the relationship) and I am trying to get a list of LotNumbers in the other table using the OrderNumberLot (the many side) to link them together, as there can be many lot numbers on one order. The primary key in tblOrderDetails is OrderNumber and the primary key in tblLotNumber is LotID (auto number), but the linked field is OrderNumberLot. I made a open form button located on frmOrderDetail to open frmLotNumbers (based on the tblLotNumber). The deal is when frmLotNumber opens the OrderNumberLot field is blank. I understand there is no associated record in tblLotNumber, because I am trying to enter it, but how do I get the OrderNumber from the previous form, frmOrderDetail, with the button to automatically populate in the OrderNumberLot field in frmLotNumbers? I certainly don't want people to have to type it, because they will screw it up as badly as I have this explanation of my question! Thanks in advance for the help.
I agree with June7 on using a subform-approach for your purpose.
If you already have created the form, you could simply drag it from the sidebar onto your mainform and set the "Link Master Fields" and "Link Child Fields" to "OrderNumber" and "OrderNumberLot" - or you just use the subform-wizard and follow its instructions.
Though, some people dislike subforms in general and try to avoid them whenever possible - which might make sense at further stages of development. Instead of subforms, you could then use vba to transfer information from one form to another.
Lets say your button is named bt_openform
Private Sub bt_openform_Click()
'Open the desired form. The option "acFormAdd" forces the form
'to add a new entry whenever loading and requerying.
'As we want to add a new record, we will not use the filter settings
DoCmd.OpenForm "frmLotNumber", , , ,acFormAdd
'Next, store information from the initial form into the newly opened form
'To refer to data from the current form (meaning the one, in which the Sub is triggerd),
'you can use "Me.fieldname" and to refer to another form, use "Forms!formname!fieldname"
Forms!frmLotNumber!OrderNumberLot = Me.OrderNumber
End Sub
You could also do it the other way around and retrieve the information when loading the form:
Private Sub Form_Load()
Me.OrderNumberLot = Forms!frmOrderDetail!OrderNumber
End Sub
To be on the safe site, one might want to nest this function in an if statement, to check whether frmOrderDetail is open or not. This way, you can open your frmLotNumber from different forms without causing troubles
If CurrentProject.AllForms("frmOrderDetail").IsLoaded Then Me.OrderNumberLot = Forms!frmOrderDetail
There is an existing Access program that I need to learn more about. There is a button in the program that, when pressed, outputs an Excel file. It queries some tables within it for the data.
How would I view the raw SQL code that this button utilizes to generate this Excel file? From the button's properties, I can see that its On Click event is "[Embedded Macro]". Also, it's object type is "Query".
Thank you in advance.
In the On Click row (under the Event tab in Properties), when I click on the ellipse next to "[Embedded Macro]", I am presented with an expandable section containing these rows:
Object Type - Query
Object Name - Inv File Query
Output Format - Excel Workbook (*.xlsx)
Output File - (blank)
Auto Start - No
Template File - (blank)
Encoding - (blank)
Output Quality - Print
I don't see any logic (SQL, VBA, etc.) listed anywhere, however, as to how Access will construct this Excel file that it exports. How would I view this logic? I figure this logic has to be stored somewhere because the button does actually return an Excel file populated with data.
You have the name of the query used here.
The SQL thus used is in a query called Inv File Query.
So you need to display the query objects in the nav pane (assuming 2007 onwards).
So choose this:
And then all of the queries used in the application will display. If the query Inv File Query does not show, it may be hidden. (to be fair, I would choose All Access objects - but for this we choose query). And hit F11 if the nav pane does not show.
If for some reason you STILL do not see the query, then you want to display hidden objects.
To display all hidden objects then right click on the top part of the nav pane (on the query) like this:
Then:
Turn all of the options, and now you should be able to see/view the SQL used for the query called Inv File Query
Open the form in Design view
Open the Properties sheet by right-clicking on the button and choosing "Properties".
In the On Click event, where you see "[Embedded Macro]", click on the ellipse on the far right
As a pointer, once you've figured out what's going on, I'd do my best to convert it all to VBA code. This will eliminate confusion in the future, and macros are really the poor man's way out of writing code anyway. I never, ever use macros in my Access apps.
I have a VBScript that I use to read an XML file and populate a couple of tables in Access 2010. The VBScript also copies jpg files from a card reader to a location on the server. The VBScript creates a unique folder based on date/time...the folder location of each image name is written to the database as one of the fields in UNC path\filename.jpg notation.
I have a primary database and the transaction (images) are referenced in the second database. I have created a relationship as well...
I am able to build my report in Access from data from both the tables, however, I'd like to automate a print job that grabs the last entry to the primary database, it's associated images (up to 10...but not 10 in every case) and print them out. When I try to build the report I cannot figure out how to use a query result of the field with the filenames to display on the report.
You can do what you describe using an Image control and a line of VBA code. For a sample table named [ImageLocations]
ImageLocation
-----------------------------------
\\SERVER\Public\Pictures\image1.jpg
\\SERVER\Public\Pictures\image2.jpg
I created a report with that table as the Record Source, dropped the [ImageLocation] field onto the Detail band, and added an Image control. I used the following as the On Format event of the report's Detail section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.ImageControl.Picture = Me.ImageLocation.Value
End Sub
When I print the report I see the images associated with the filenames in the table.
Edit re: comment
Newer versions of Access (since at least Access 2010) do not need the On Format VBA code. We can simply place an Image control on the report and set its Control Source property to the (text) field containing the path to the image file. Thanks to Albert D. Kallal for the tip!
Software: Microsoft Access 2007 SP2
Database File Version: Access 2000
I have an access program that I inherited from a previous employee. It uses forms for reports and since I don't have much experience in access I have continued to do this. I have created a copy of the program for another project and modified it to suit.
I am having trouble getting more then one chart to print. All the charts display in form view, they all have the same properties (excepting data, position, etc.) For some reason they are not printing. They don't even show up in the print preview.
I am thinking it must be something with the graphs themselves as they sometimes lose all information. I have to open the graphs in edit mode and change the data source from column to row and back again so that it gets redrawn. (Refresh doesn't fix it)
So right now I don't even have a clue as to where to look so ideas are welcome.
Edit #1
It seems to be a problem with linking to an unbound form.
Subform Field Linker:
Can't build a link between unbound forms.
The query for the main form is
SELECT tTest.ixTest, tMotorTypes.ixMotorType, tMotorTypes.asMotorType, tMotorTypes.fDeprecated, tTestType.asTest, tTest.asSerialNum, tTest.asOrderNum, tTest.asFrameNum, tTest.asRotorNum, tTest.asOperator, tTest.iStation, tTest.dtTestDate, tTest.ixTestType
FROM tMotorTypes
INNER JOIN (tTestType
INNER JOIN tTest ON tTestType.ixTestType=tTest.ixTestType)
ON tMotorTypes.ixMotorType=tTest.ixMotorType;
The query for the chart is:
SELECT qGraphRSTTemperatures.Frequency, qGraphRSTTemperatures.[Drive End], qGraphRSTTemperatures.[Non Drive End], qGraphRSTTemperatures.[Air In], qGraphRSTTemperatures.Core
FROM qGraphRSTTemperatures
ORDER BY qGraphRSTTemperatures.ixTemperature;
Query qGraphRSTTemperatures:
SELECT tElectricalData.dblFrequency AS Frequency, tTemperatures.dblDrvEnd AS [Drive End], tTemperatures.dblNonDrvEnd AS [Non Drive End], tTemperatures.dblAirIn AS [Air In], tTemperatures.dblCore AS Core, tSubTest.ixTest, tTemperatures.ixTemperature
FROM (tSubTest INNER JOIN tElectricalData ON tSubTest.ixSubTest = tElectricalData.ixSubTest)
LEFT JOIN tTemperatures ON tElectricalData.ixElectrical = tTemperatures.ixElectrical
WHERE (((tSubTest.ixSubTestType)=5))
ORDER BY tSubTest.ixTest, tTemperatures.ixTemperature;
So how come, in the form view it shows the graph with the correct data when linked thus:
Child field: ixTest
Master field: ixTest
but won't print the graph.
The graph will print if I remove the links, but then I have all the data from chart query as it is not limited by ixTest.
edit #2
It seems to be a data retrieval/rendering issue in printing. Is there anything in printing that changes the context of records with respect to parent/child relationships?
Check the "Display When" Property of the control and make sure it's set to "Always" (if you do it via code then Always is 0).
Some other things to look for would be the "Auto Activate" property. I believe it's set to "double click" by default.
My solution to work around the problem.
I created separate reports with the graphs/charts in them. I just copied & pasted the charts from the forms into the reports and they worked.
I didn't want to do it this way as it uses a couple sheets of paper more than before. I am also dissatisfied with this solution as the question of why still remains.
Ran into a similar problem... Reports with graphs were working fine until I had an invalid syntax issue with the report code that I did not catch.
apparently the code for the report would not compile correctly, so it did not link up to the graphs and sub reports correctly and I would get the same errors even when manually putting in the link fields.
My advice would be to check the code on the form or report... then compile the code and fix any problmes. Hope this helps.
I have a similar problem with a report. I created a graph that is in a group to give me a separate graph for each category (say divisions). The graphs all display fine in the report view (for each division) and the print preview but when I print to a pdf only the first graph prints. If I open the report and go to the print preview and then print to a PDF it works great. If this is the problem you are having here is my work around:
I used VBA to follow a sequence to solve the problem. When a button is clicked on my main form the following events happen (1)Open the report in print preview (hidden), (2)open the print dialog box, after the PDF has been created the (3)report closes.
Dim stDocName As String
stDocName = "My Reports Name"
(1) DoCmd.OpenReport stDocName, acViewPreview, , , acHidden
(2) DoCmd.RunCommand acCmdPrint
(3) DoCmd.Close acReport, "My Reports Name"