MS Access: Query to list number of files in a series of folders - sql

I have folders labeled by their keyfield, so 1, 2, ... 999, 1000. located in currentproject.path\RecordFiles\KeyFieldHere so like currentproject.path\RecordFiles\917.
I want to run a query that will count how many files are in each folder. I know this can be done with the DIR function through visual basic, but I can't seem to run it through a SQL query.
I've tried using this function in a SQL equation, so Expr1: [FlrFileCount("Y:\Education\Databases\RecordFiles\")] as one of the fields just to see if it can work, but it prompts me for a value and then returns nothing.
EDIT: I tried an approach using the FlrFileCount function in a continuous form, and it does work, BUT... I get an error after every single line. I have a field in a continuous form of =FlrFileCount([currentproject].[path] & "\recordfiles\" & [ID]), but when I run the form I get an error "Error 76, Error source: FlrFileCount, Error description: Path not found." Which is crazy because IT WORKS, it properly lists the number of files in the folder for each record.
I just need to get this functionality over into a SQL query so I can pull that data for mail merges.
I currently have something similar in a form. The form has an onload property to run a module (Link here) to create a list of all the files in the relevant folder to that record, and then I have another field that just counts the number of entries in the list. However a list can't be a value in a SQL query, so I don't think that code will help.

Thanks to Tim Williams, the answer was to put
=FlrFileCount(Currentproject.Path & "\recordfiles\" & [ID])
It seems the [currentproject].[path] part was where the error was. What's confusing is that in other places, MS Access adds the extra [] around currentproject and path, and I don't know why.
Thank you so much for your help! Now to the tricky part: Implementing a proper naming scheme by program ID across a sharepoint so that the relevant folder can be opened consistently even when program names change.

Related

Get upercase within String Value

I am currently working on a tool to automatically send out emails.
Within this tool one variable is the pathway in which the attachment is to be found.
The file names are automatically generated within a folder, but sometimes got strange symbols and/or uppercase letters, like this: "Sⁿkwrld.xlsx".
By collecting this value within a string, VBA retrieves: "Snkwrld.xlsx". This results in not being able to find the right file.
Is there a way to fix this problem and let VBA retrieve the correct value with the uppercase "N"?
Thanks in advance!
Best Regards,
Remco Coppens

MSP resource assignment issue using vba

I am working on a huge set of macros to read workload data from MSP files and Excel files to update a master planning and a resource pool (both MSP).
My Excel files all have same template and list tasks, start dates, end dates and allocated resources and look like this
The task is created by the macro, with Start Date and End Date. This part works fine. Even Outline level works fine.
Macro reads data in Excel's column 12 to get resource names (stored in an array) and cross checks name with names listed in resource pool (stored in a second array ResPoolArr along with corresponding ID).
My issue is that Ta.Assignments.Add ResourceID:=ResPoolArr(RowResPoolArr, 1), Units:=1 returns a 'The resource does not exist' error while I get an effective ID (e.g. ResPoolArr(RowResPoolArr, 1) = 50)
I also tried another way round by using Ta.Resources.Add() but it didn't work either.
Ta.Assignments.Add Ta.id, ResPoolArr(RowResPoolArr, 1) works and solved my issue

Applescript in reverse?

& thanks for all the tips i've had here... this site is ace!
My question is, basically, how to correctly write my script. I've written an applescript, that works great for 1 variable, but i'll need to add hundreds of variables, and that'll currently mean adding hundreds of "if" statements.
So my script queries a FileMaker database & receives an input field (which is variable), i then want to open a the related textEdit file & read the text.
ie... FileMaker Pro returns "123", so i want to open textEdit file "123".
However, my script currently says If text returned is "123" then do this, else if text returned is "234" do this, else if text returned is "345" do this. To write this script with hundreds of "Ifs" doesn't make sense, but i can't get my head around swapping my script to say - returned value is "123" so use file 123.
Does anyone have a suggestion?
Thanks

In VB.net is there an option to force generation of the counter variable in the "Next" statement?

Visual Basic .net automatically inserts a "Next" statement when you enter a "For" statement; e.g., if I type:
For i as integer = 1 to 10
a Next will automatically be inserted, so that the code looks like:
For i as integer = 1 to 10
Next
It is optional to put the counter variable ("i" in the above) in the Next statement, so that it would read:
Next i
I'd really like to make this the default, as it really helps when one has nested For statements. I can't find anything in the Visual Studio settings to do this; maybe it's partly buried somewhere in Intellisense. I thought perhaps someone out there has already figured this out.
You will want to modify the .snippet file associated with the pattern. For the one you are looking for it is, by default:
VisualStudioInstallDirectory\VB\Snippets\1033\common code patterns\conditionals and loops\ForEachNext.snippet
You can also track down the exact location by looking in
Tools > Code Snippets Manager..., select Visual Basic for the language and browse to Code Patterns - If, For Each, Try Catch, Property, etc - the file location will be listed there.

Creating a self test program with save/import functions (images, description inside)

I'm basically trying to create a program that will allow me to use textboxes to input questions and associated answers to test myself. Mostly, I just want to practice some things I've been learning for vb.net while taking an extra step forward.
Here's a mockup:
Any tips on how to do this? What I'm especially not sure about is how to have the textfile save/import work with adding back into comboboxes and making sure the correct questions and answers are associated with one another. I was thinking also that I could have some sort of check when I import a save file that shows me which questions and answers refer to one another
Update on form design:
Some things I'm trying to practice:
Using arrays
Saving/Opening files (text files in this)- in order to import into program
importing into program
Using the progress bar
Having a way to undo entries
Randomizing sort order in the combo box
Maintaining references between variables (like which answer
corresponds with which question) regardless of sort order or using
the undo function
Some posts in stackoverflow I'm thinking of using as reference:
Compare String with Strings in array
Best way to associate two strings of text in VB.NET
Array to combo box?
Update: Trying to be more specific on my question. Basically, I'm trying to use a list to account for all the inputted questions and answers, however I've only used really basic arrays before, like:
val(1) = "test"
val(2) = "this"
val(3) = "string"
Or the kind where you use a For x to z loop. Based on some stackoverflow posts I've gotten to the point where the code works in that (I think?) the list is updated and the combobox for questions and answers reflect what is on the list. However, I can't connect the two so that I can select things in the comboboxes and check if they are correct.
In terms of saving as a text file. I figured it would be simpler. Basically, have it output sort of like
"question goes here" ; "answer goes here"
"next question goes here" ; "answer goes here"
and so on. Then I can use the semicolon as reference in the code when importing. I've never done it before, but it's generally what I do for Microsoft Access or Excel text imports so I figured it was possible.
Code that I have so far (reddit post link): http://redd.it/2716tw