Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use the "Form" property on a "SubForm" object in MS Access?

I'm trying to fix a problem with a MS Access database (.mdb) which I didn't create and it was working fine on another computer which broke, there is a dropdown to select from a value which should fill a table under the dropdown with the result of a query depending on the value selected, the error is a Run-time error:

Method 'Form' of object '_SubForm' failed

So I clicked on debug, and I got a list of if statements that check for the dropdown value:

If dropdown = 1 Then
    Forms!mylist![namelist subform].Form.RecordSource = "SELECT ...  ;"
Else
If dropdown = 2 Then
    Forms!mylist![namelist subform].Form.RecordSource = "SELECT ...  ;"
Else

The error is coming from:

Forms!mylist![namelist subform].Form

I tried to find out the type of the object:

Debug.Print TypeName(Forms!mylist![namelist subform])

it printed SubForm and in the docs there is Form under the SubForm properties, so what could be causing this problem ?

Excuse me if this question is stupid or very easy, but I don't know anything about Visual Basic and everything above I learned today just to fix the problem, so sorry about that.

T think the database is created on MS Access 2003, I tried the database on Access 2003 and 2007 on XP SP3 and Windows 7 and it didn't work, but it worked on Access 2007 on XP SP3 on a computer that I don't have access to anymore.

So what could be causing this problem ? is it a coding problem or am I missing some dependencies ?

like image 385
Pierre Avatar asked Oct 17 '25 03:10

Pierre


1 Answers

When you have a problem with a form, there are various things to check:

  • Have you got the right names?
  • Have you tried a compile (Code window, Debug-->Compile)?
  • Have you compacted and repaired?
  • Have you decompiled?
  • Sometimes you may need to recreate the form by copying to text and then importing. (Refer to Application.SaveAsText acForm )
  • Check for missing references (Code window, Tools --> References). You can get very weird errors totally unrelated to the missing reference.
like image 197
Fionnuala Avatar answered Oct 20 '25 00:10

Fionnuala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!