Question

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 ?

Was it helpful?

Solution

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

OTHER TIPS

You should use dot notation here.

And assuming this code runs in the same form, then this should work:

Me.namelist_subform.Form.RecordSource  = "select * from qyCustChild"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top