I have exhausted every resource I can find and before I determine my Access DB to be corrupt I wanted to post this question:
I am working on a tool that will import the data from an Excel form that is to be distributed to a couple hundred individuals. I have created an Access form in parallel and I am trying to create a macro that will auto-populate the Access form fields with the data from the Excel form.
Here is the code I am working with:
Sub Import_Click()
Dim objDialog As Object
Dim CEtarget As Form
Dim CEfile As String
Set CEtarget = Forms("Data Entry")
Set CEsource = Excel.Application
Set objDialog = Application.FileDialog(3)
With objDialog
.AllowMultiSelect = False
.Title = "Select Form"
.filters.Clear
.filters.Add "*.xlsm; *.xlsx; *.xls", "*.xlsm; *.xlsx; *.xls"
.Show
If .SelectedItems.Count = 0 Then
Exit Sub
Else
CEfile = .SelectedItems(1)
CEsource.Workbooks.Open (CEfile)
CEsource.Visible = True
End If
CEtarget.FirstName.Value = CEsource.Range("B14")
End Sub
The error occurs at the following string:
Set CEtarget = Forms("Data Entry")
I receive the following error:
Run-time Error '-2146500594 (800f000e)': Method 'Item' of object 'Forms' failed
Not sure what could be wrong. I did have the code working at one point, but somehow I started seeing that error message.
EDIT:I tested the code while the form was in Design View and it executed without any problems. The error prompt still persists while in Form and Layout View.