Avatar of ckangas7
ckangas7 asked on

Referencing checkbox on form from Module

This is a simple one, but I still don't quite understand the naming / path references to object in Access VBA.  I have a checkbox called sparbox on a form named Spartan Report Dialog.  I am trying to reference the checkbox in the following module.  I tried
If Sparbox
If Me!Sparbox
and what you see below.  What is the correct way to reference the location of my checkbox object?

Sub rename()
Dim objWMI: Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If Forms![Spartan Report Dialog]!Me!sparbox = True Then
Set colFiles = objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='C:\Central Billing\Import\Spartan'} Where ResultClass = CIM_DataFile")
Set colFiles = objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='C:\Central Billing\Import'} Where ResultClass = CIM_DataFile")
End If
For Each objFile In colFiles
  If LCase(objFile.Extension) = "psd" Then objFile.rename (Replace(LCase(objFile.Name), ".psd", ".csv"))
End Sub

Open in new window

Visual Basic ClassicVB ScriptMicrosoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Excellent Thanks much.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy