Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why "subscript out of range" when trying to create a subform?

Status
Not open for further replies.

kuanli

Technical User
Jan 28, 2002
22
CA
I'm trying to use Subform wizard to create a subform within a subform. The relationship between the two forms are one-to-many, and it is based on a two-field primary key (Info_num and offence_code). But when I cliked "finish", a window pops up saying "Subscript out of range". Could anyone tell me what it means?

I also tried to avoid the problem by creating the subform as a form and then drag it into its parent form, but then I couldn't enter any data because it complains that the parent form doesn't have a related a record. Even when there is!

The form is organized like this:
Main form: Info_num, ...
1st level subform: Info_num, Offence_code, ...
2nd level subform: Info_num, Offence_code, sentence, ...

Any help is greatly appreciated.

Kuan
 
You should not try and use a multiple key field as your linking field. Instead, create an autonumber psuedo-primary key field in the master table and link to it in the subtables. "Advice is a dangerous gift, even from the wise to the wise, for all course may run ill." J.R.R. Tolkien
 
Thanks a lot for the response.

Now I know what the problem is. But how do I link a subform using an autonumber? The form is used for data entry. Does it mean that the person has to first find out what autonumber is created in the master table and then type it into the subform?

Kuan
 
No, Access will handle this for you. Just make sure the subform's Master/Child properties are set to the join field from each table. "Advice is a dangerous gift, even from the wise to the wise, for all course may run ill." J.R.R. Tolkien
 
I got a new problem (or the old problem in a new form) this time.

I created an autonumber primary key in the master table, linked it to a long integer field in the child table. The one-to-many table relationship seemed fine.

I again created the subform using subform wizard. When I try to enter information in the subform, this message came up: "The LinkMasterFields property setting has produced this error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control".

If I ignore it and carry on, I see this message: "You cannot add or change a record because a related record is required in table 'master table'".

Please help.

Kuan
 
Hi JerryDennison,

I got it! All I had to do was to delete all the records and subforms and start from fresh.

Thank you very much! I'm so happy that I don't need to carry this problem into the weekend.

Have a nice weekend!

Kuan
 
You're welcome. "Advice is a dangerous gift, even from the wise to the wise, for all course may run ill." J.R.R. Tolkien
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top