4

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 ?

8
  • Are you sure you have the right names ( wiki.lessthandot.com/… )? Have you tried a compile? Have you compacted and repaired? Have you decompiled? Sometimes you may need to recreate the form by copying to text and then importing. Commented Mar 8, 2014 at 15:09
  • @Remou the problem is I don't know anything at all about VBA so I don't know how to do what you suggested. Commented Mar 8, 2014 at 15:15
  • 1
    Half the stuff I suggested was not VBA, for example decompile stackoverflow.com/questions/3266542/…, compact and repair office.microsoft.com/en-ie/access-help/… Commented Mar 8, 2014 at 15:31
  • Is the database confidential? Can you upload it to a file sharing site? Commented Mar 8, 2014 at 15:41
  • 1
    Check out granite.ab.ca/access/corruption/corruptobjects.htm with reference to Application.SaveAsText acForm Commented Mar 8, 2014 at 15:58

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

recreating the form worked for me today in Access 2013 on Win10... phew!
1

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.