Unable to add records to sub form

nika.duncan

Registered User.
Local time
Today, 14:56
Joined
Sep 23, 2013
Messages
10
Hi All,
I have created three forms using three tables tblUser, tlbMeasure and tblSubMeasure. The tblUser is linked to the tblMeasure table via UserLogin and tblMeasure is linked to tblSubMeasure via MeasureID. The forms are created with frmMainMeasure being the main form and frmMeasure6 a subform and frmSubMeasure a sub with frmMeasure6.

I want to be able to add sub measures that will be linked to each MeasureID and each MeasureID link to each user via UserloginID. The forms load the data in the sub forms but when I try to add sub measures using a button I added on the frmMeasures6. The button works when I try work on the form fine but when I try via the main form I am not able to add or view other records within the table.
When I click the Add button I want to be able to load back the same MeasureID number in fmrSubMeasure to ensure that it is linked to the same measure and the MeasureID is linked to the same UsrrLoginID.
I am seeking any help possible. The code is included below and I've attached the file as well.

Thanks for any help.

Code:
Private Sub cmdAdd_Click()
If Me!frmSubMeasure.Form.Dirty = False Then
End If
Me!frmSubMeasure.SetFocus

DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub cmdFindNext_Click()
If Me!frmSubMeasure.Form.Dirty = False Then
End If
Me!frmSubMeasure.SetFocus

'DoCmd.GoToRecord , , acNext
'DoCmd.GoToRecord acDataForm, frmSubMeasure, acNext
'DoCmd.OpenTable tblSubMeasure, acViewNormal, acEdit
'DoCmd.Minimize
DoCmd.GoToRecord acDataTable, tblSubMeasure, acNext
'DoCmd.Close acTable, tblSubMeasure, acSaveYes





End Sub
 

Attachments

Last edited:
Your table design leave a lot to be desired. For a start your form is using to link to the subform, the FK in tblMeasures (MuserLoginID) on the PK in tblUsers (UserLoginID). What are you going to do when there are 2 users with the same name?

Use Autonumbers as primary keys and make life easier for everyone by using the same name for then PK and the FK.

I know I haven't answered your basic query but others will no doubt have more tolerance than me to wade through the decyphering required as is.
 

Users who are viewing this thread

Back
Top Bottom