Hi Guys,
I have a main form with a suform. The information on the main form is "read only" and the subform is used for data entry.
I have a cbo that is used to find personnel and this is located on the main form. When I select personnel with the cbo, this populates the main form fields and only the ID in the subform.
I have the subform setup for data entry, so the only thing that is default is the ID number of the member. The ID is populated from the main form.
When I move through the personnel, the ID in the subform is the same as the main form. This worked fine, but now all the fields of the subform are being populated with a record. I want "data entry" only.
To work around this (I am not sure if this is the correct way) I placed the following code in the Current event of the subform:
and this seems to work.
My question is: what went wrong? Also, can I use the same code above in the click event of the "Save" button to clear the fields at one time?
I think the above may be Pat's code from another post for the "Cancel".
Another question: why is it when I place the docmd under the "Save" (in Case Select), it will not work?
Sorry for the length and I hope I am making this somewhat understandable, lol.
Man, I have another question: Should the command buttons be on the main form?
Also, after I click the "Cancel" button and then try to select another member from the cbo on the main form I get the msgbox from the beforeupdate event of the subform, why?
I have a main form with a suform. The information on the main form is "read only" and the subform is used for data entry.
I have a cbo that is used to find personnel and this is located on the main form. When I select personnel with the cbo, this populates the main form fields and only the ID in the subform.
I have the subform setup for data entry, so the only thing that is default is the ID number of the member. The ID is populated from the main form.
When I move through the personnel, the ID in the subform is the same as the main form. This worked fine, but now all the fields of the subform are being populated with a record. I want "data entry" only.
To work around this (I am not sure if this is the correct way) I placed the following code in the Current event of the subform:
Code:
Me.Form.DataEntry = True
and this seems to work.
My question is: what went wrong? Also, can I use the same code above in the click event of the "Save" button to clear the fields at one time?
Code:
Private Sub Form_Current()
Me.Form.DataEntry = True
End Sub
Code:
Private Sub cmdSave_Click()
MyAction = "Save"
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Record Saved!", vbOKOnly + vbInformation
End Sub
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Select Case MyAction
Case "Cancel"
If MsgBox("Do you want to cancel this update?", vbYesNo) = vbYes Then
Cancel = True
Exit Sub
End If
Case "Save"
Case Else
MsgBox "Please press the Save or Cancel button", vbOKOnly
Cancel = True
Exit Sub
End Select
End Sub
I think the above may be Pat's code from another post for the "Cancel".
Another question: why is it when I place the docmd under the "Save" (in Case Select), it will not work?
Sorry for the length and I hope I am making this somewhat understandable, lol.
Man, I have another question: Should the command buttons be on the main form?
Also, after I click the "Cancel" button and then try to select another member from the cbo on the main form I get the msgbox from the beforeupdate event of the subform, why?
Last edited: