Run Time Error - create file folder (1 Viewer)

JA2020

New member
Local time
Today, 12:20
Joined
Jun 10, 2020
Messages
2
Hello, first time posting and complete VBA newbie. I've been tasked with creating a "quote database" for my company. I have a database that holds most of the information as well as a form to populate said table. In my system, we have a generic file folder named quote template folder, which gets copied and saved with the new quote number such that for every new quote a new quote folder is saved. I've programmed a button on my form so that when clicked, the code is run to capture that quote number (Primary key of quote database) and create the new folder on the server. The primary key ID is formatted in the way "Q13"000 so Q13 is always in the quote number.

When I click the button on the form I get runtime error 2465 "Microsoft access can't find the field '|1' referred to in your expression. When I debug/step into it fails on the QuoteNumber= line

Any help would be awesome, I've been working at solving this for hours.

QuoteNumber = [ID]
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.copyFolder "\server\Shop Management\active quotes\_Quote File Template", _
"\\server\QTS Shop Management\active quotes\" & QuoteNumber
Set FSO = Nothing

Dim OldName1, NewName1
OldName1 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\Communications": _
NewName1 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\" & QuoteNumber & "_Communications"
Name OldName1 As NewName1

Dim OldName2, NewName2
OldName2 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\Customer Files": _
NewName2 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\" & QuoteNumber & "_Customer Files"
Name OldName2 As NewName2

Dim OldName3, NewName3
OldName3 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\\Quote template.xls":
NewName3 = "\\server\Shop Management\active quotes\" & QuoteNumber & "\" & QuoteNumber & ".xls"
Name OldName3 As NewName3


End Sub
 

Minty

AWF VIP
Local time
Today, 18:20
Joined
Jul 26, 2013
Messages
10,367
The error message is telling you that it can't find [ID], so I'm guessing it's called something else or isn't available on the form this is run from.

If the ID is in a control (and ID is a poor choice of for a field name, try QuoteID or something more descriptive!) try referring to it using

Me.MyControlName

Replacing MyControlName with the actual name of the control holding the ID
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:20
Joined
Oct 29, 2018
Messages
21,447
Hi. Welcome to AWF!

Where is this code located? Is it on a Form with your button? If so, is the form bound to the table where the ID is stored?
 

JA2020

New member
Local time
Today, 12:20
Joined
Jun 10, 2020
Messages
2
Thanks! The code is located on the form as an event under "on click" and the form was created using the wizard from the table, I just moved things around a bit and added a couple buttons. I did remove the [ID] and replaced it with the actual table header which was "QuoteNumber" and it let me step through the code until the next error (which is just a file location error).

Thanks again for the help!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:20
Joined
Oct 29, 2018
Messages
21,447
Thanks! The code is located on the form as an event under "on click" and the form was created using the wizard from the table, I just moved things around a bit and added a couple buttons. I did remove the [ID] and replaced it with the actual table header which was "QuoteNumber" and it let me step through the code until the next error (which is just a file location error).

Thanks again for the help!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom