0
votes

I have a database that was create in Access 2010. We recently updated our systems to Access 2013. In Access 2010 I have no errors accessing a form object with

Form_frmName.txtFieldName.Value

However, when using Access 2013 I get a runtime 2424 error stating that "The expression you entered has a field, control, or property name that Microsoft Access can't find. I am accessing from a module.

The module sets these fields visible using

With Form_frmName
.txtFieldName.Visible = True
End With

before attempting to access them.

Has there been any changes in the way form objects are accessed between 2010 and 2013? Is this an issue others have faced?

In Response to @WayneGDunn's questions below

QUOTE: I need to know exactly what and how you are using this. 1. You have a bound textbox named 'txtFieldName' on a form. As @brad asked, is there a subform, and if so, is this field on the subform? 2. You said the code is in a module, but is the code in the form where the field is defined? 3. Please explain where/what form 'frmQAtab' is (you said your form name was 'frmName', so what is the other, how related?) 4. Is the code in an event? Can you share the entire subroutine? 5. Have you tried creating a dummy query and using the builder to reference the field?

RESPONSE: 1. I have a form (frmMain) with multiple tabbed pages. frmName is one of those tabs, containing the bound field txtFieldName. 2. The module is run from the form the field is in. 3. My apologies frmQAtab is frmName, I just neglected to make that generic in my copy-paste. 4. The event is a button click. The button click runs a sub from a module. That sub makes visible the fields, runs a query based on user input (two date fields), populates the bound fields with the returned record set, then attempts to access them for processing (another query is run to process a complete other set of fields). To post the entire subroutine would be a bit more than I would ask you to chew on. This is legacy code I'm trying to fix, and it's rather large. 5. I have not tried a dummy query. Access is not my field (I'm mainly a C#, scripting, guy.) Is there some suggestions in this area you could give?

1
Where are you referencing the form object from? Is it within the same form, or from another form, or from a module? - Wayne G. Dunn
@WayneG.Dunn A module. I've edited the OP to reflected that. - steventnorris
Try using: Forms!Form1.txtPDFFile.Visible = True - Wayne G. Dunn
@WayneG.Dunn The visibility portion is working fine. It's when I attempt to access the values that it fails. Can you explain the connection between changing the visibility to fix the values? - steventnorris
@WayneG.Dunn In addition, I did attempt to do Forms!frmName.txFieldName.Visible = True, and I get the error Run-Time Error 2450 "Microsoft Access cannot find the reference form 'frmQAtab' - steventnorris

1 Answers

0
votes

One of the following references to your fields should work. I created a form (named 'frmMain'), then created a Tab Control with two tabs. On the first tab, I inserted another form (named 'frm3197'). I also created a text box on the tab control named 'txtFieldName' AND in form 'frm3197'. From a button click on 'frmMain', the following will reference each of those fields.

Private Sub cmdButton1_Click()
    Forms![frmMain]![txtFieldName] = Now()
    Forms![frmMain]![frm3197].Form![txtFieldName] = Now()
End Sub