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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have two problems that arose afte

Status
Not open for further replies.

cochise

Technical User
Mar 27, 2001
171
US
I have two problems that arose after converting a form into main/sub forms. Here is the new forms layout.

Main Form (frmTimeCard) - cmbEmpNum (tblEmpInfo)
txtDate (tblTimeCard)

Sub Form (sfrmTimeCard) [based on tblTimeCard]

tblTimeCard's primary key is EmpNum and txtDate.

On load, a new record appears. After choosing a EmpNum and entering a date, tab jumps to the subform. However, when I try to enter info into the first subform field, TimeIn, I get the following error message: (might be useful to know that I deleted the controls txtEmpNum & txtDate from the subform b/c i didn't want the form to be redundant)

A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX control.


The second problem is that after entering info on the subform when I try to save the record, I get a message saying the there needs to be a valid primary key.

Any help would be greatly appreciated.
 
I think that you have answered the problem yourself: you say you removed the primary fields from the subform. Linking a main form and a sub form is alike linking two tables; you need a key field to keep the two synchronised.

If you double click the subform while the main form is in design view you can check out the current property settings for the Child-field/Parent-field relationship.

If you have difficulty setting this up my recommendation is that you make a careful note of the fields the subform contains then delete the subform altogether. Switch on the Wizards option on the Toolbox menu and click on the build a subform button to recreate the subform using the Wizard. Let Access do the work for you; while its a bit clumsy at setting out the subform's appearance it should enable you to get the subform/mainform relationships right.
 
Cochise,
I think I see what you're trying to do here. You'll need to make sure that your table for workshift time records has a primary key (autonumber?) and the foreign key of the employee id. Same datatype. If you used autonumber in the employee table, make the field a long integer in the work table.

Also, with parent forms and child forms using the subform control the LINK FIELDS properties of the subform control enforces the filtering of the subform's recordset. So, look at your raw data for each of these forms and see if that's the case.

Finally, if the concept of subform recordsets doesn't seem real clear to you, and it's not an easy one, try using a wizard to make the form first. Use it as a simple prototype to check its properties and see how it works. Then try making your own from what you've learned.

Hope this helps a little.
DoogieB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top